Commit Graph

36606 Commits

Author SHA1 Message Date
Ryan Liptak 406950f756 std.process: Fix executableDirPath functions 2025-12-23 22:15:10 -08:00
Ryan Liptak 8767a9a6d1 testFilenameLimits: Fix collision with dir and filename 2025-12-23 22:15:10 -08:00
Andrew Kelley c1b9c46319 std.Io: introduce path_only to File.OpenFlags 2025-12-23 22:15:10 -08:00
Andrew Kelley f27bd87ade std.Io.Threaded: allow length-0 file writes
At first I thought about keeping this as an assertion but I can see this
being useful if you already know how many bytes to read and you are
filling the end of the buffer.

This also more closely mirrors POSIX APIs.
2025-12-23 22:15:10 -08:00
Andrew Kelley 6f00157e1e std: fix "open smoke test" by passing allow_directory option 2025-12-23 22:15:10 -08:00
Andrew Kelley 47a2e8026f std.Io.Threaded: fix dirDeleteDir when not empty 2025-12-23 22:15:10 -08:00
Andrew Kelley 651ff9f9ee std.Io.Threaded: implement dirHardLink 2025-12-23 22:15:10 -08:00
Andrew Kelley 7ce5ee2e92 std: update remaining unit tests for std.Io API changes 2025-12-23 22:15:10 -08:00
Andrew Kelley 21d0264c61 std.dynamic_library: use a global static single threaded Io
See #30150
2025-12-23 22:15:10 -08:00
Andrew Kelley 8632a28ca9 std: add support for realpath on file handle
and rename OperationNotSupported to OperationUnsupported
2025-12-23 22:15:10 -08:00
Andrew Kelley 9bbb8e0d8e std.posix: make nlink_t on unsupported systems u0
instead of void
2025-12-23 22:15:10 -08:00
Ryan Liptak f078c7138f std: Update/fix some usages/implementations of std.Io APIs 2025-12-23 22:15:10 -08:00
Ryan Liptak 1edae601a1 Test Dir.Reader.min_buffer_len via "max file name component lengths" test 2025-12-23 22:15:10 -08:00
Andrew Kelley 3466056478 std.Io.Dir.CopyFileOptions: rename override_permissions
to more simply `permissions`.

In master branch this was `override_mode`.
2025-12-23 22:15:10 -08:00
Andrew Kelley d8b1cc953e std.Io.Dir.renameAbsolute: consistent parameter order 2025-12-23 22:15:10 -08:00
Andrew Kelley e205b13ffb std.os.linux.IoUring: update for new fs API
and split out tests into a separate file
2025-12-23 22:15:10 -08:00
Andrew Kelley b4bfd501ae std: move some tests from posix to fs 2025-12-23 22:15:10 -08:00
Andrew Kelley f3723b42e1 std.Io: add unimplemented hard link API to File and Dir 2025-12-23 22:15:10 -08:00
Andrew Kelley 446c145ca8 std.Io.Threaded: fix compilation errors on posix 2025-12-23 22:15:10 -08:00
Ryan Liptak a2416c685a Implement dirReadWindows 2025-12-23 22:15:10 -08:00
Ryan Liptak d72983da44 File.OpenFlags: Add allow_directory and default it to true
This is one way of addressing/closing https://github.com/ziglang/zig/issues/16738

Previously, there was a mismatch between the default behaviors on Windows vs other platforms, where Windows was implicitly using .NON_DIRECTORY_FILE for its `openFile` implementation which caused `error.IsDir` when opening a directory, while on other platforms there is no equivalent flag for the `open` syscall. This meant that `openFile` on a path of a directory would fail on Windows but succeed on other platforms.

Adding `allow_directory` to `File.OpenFlags` serves two purposes:

1. It provides a cross-platform way to get the `.NON_DIRECTORY_FILE` behavior in the most efficient available way for the platform (on Windows, no extra syscalls are required, on other systems, an extra `fstat` is required)
2. It allows `statFile` to be implemented on top of `openFile` on Windows while still allowing `statFile` to work on directory paths. Before this commit, `statFile` on a directory path on Windows failed with `error.IsDir`

Note: The second purpose could have been addressed in different ways (bespoke call to NtCreateFile in the `statFile` implementation to avoid passing `NON_DIRECTORY_FILE`, or just never pass `NON_DIRECTORY_FILE` in the `openFile` implementation), so the first purpose is the more relevant/motivating force behind this change.

The default being `true` is intended to cut down on the number of syscalls as much as possible when using the default flags.
2025-12-23 22:15:10 -08:00
Andrew Kelley 1264469a41 compiler: fix build from source on macOS 2025-12-23 22:15:10 -08:00
Andrew Kelley 54865e0483 compiler: fix compilation when linking libc 2025-12-23 22:15:10 -08:00
Andrew Kelley a5b719e9eb compiler: fix build failures from std.Io-fs 2025-12-23 22:15:10 -08:00
Andrew Kelley 608145c2f0 fix more fallout from locking stderr 2025-12-23 22:15:10 -08:00
Andrew Kelley aa57793b68 std: rework locking stderr 2025-12-23 22:15:09 -08:00
Andrew Kelley 97f106f949 std.Io: fix dir iteration on macOS 2025-12-23 22:15:09 -08:00
Andrew Kelley 22afd168d9 fix build runner compilation errors on macOS 2025-12-23 22:15:09 -08:00
Andrew Kelley 9407ad8516 std.c.utimensat: add const 2025-12-23 22:15:09 -08:00
Andrew Kelley 16bd2e137e compiler: fix most compilation errors from std.fs changes 2025-12-23 22:15:09 -08:00
Andrew Kelley 4458e423bf link.MappedFile: update statx usage 2025-12-23 22:15:09 -08:00
Andrew Kelley 2a40c1b556 std.Io.Threaded: update call to statx 2025-12-23 22:15:09 -08:00
Andrew Kelley f82e7dfbc0 std.os.linux: move statx docs to proper location 2025-12-23 22:15:09 -08:00
Andrew Kelley 1925e0319f update lockStderrWriter sites
use the application's Io implementation where possible. This correctly
makes writing to stderr cancelable, fallible, and participate in the
application's event loop. It also removes one more hard-coded
dependency on a secondary Io implementation.
2025-12-23 22:15:09 -08:00
Andrew Kelley ec56696503 std.process.cleanExit: take an Io parameter
In case exit(0) will be called, this provides the opportunity for the
application's Io instance to be the one to clear the terminal in case
std.Progress or similar was used.
2025-12-23 22:15:09 -08:00
Andrew Kelley e68ae8d7a1 update uses of std.debug.lockStdErr 2025-12-23 22:15:09 -08:00
Andrew Kelley 54e4a3456c link: update to new file system APIs 2025-12-23 22:15:09 -08:00
Andrew Kelley 22b0eea3c0 std.Io.Dir: improve realPath documentation 2025-12-23 22:15:09 -08:00
Andrew Kelley 6484101f78 update occurences of std.fs.openDirAbsolute 2025-12-23 22:15:09 -08:00
Andrew Kelley 1ed845e1f6 update occurences of setEndPos to setLength 2025-12-23 22:15:09 -08:00
Andrew Kelley 16f8af1b9a compiler: update various code to new fs API 2025-12-23 22:15:09 -08:00
Andrew Kelley e1cf753db7 std: update fchmodat tests 2025-12-23 22:15:09 -08:00
Andrew Kelley 68621afd2e std.tar: update fs API calls to take io argument 2025-12-23 22:15:09 -08:00
Andrew Kelley 0e230993d5 std.Io.Dir: add setFilePermissions and setFileOwner 2025-12-23 22:15:09 -08:00
Andrew Kelley c4cefd6835 std.Build.Step.Run: restore Color.inherit logic 2025-12-23 22:15:09 -08:00
Andrew Kelley 91fa252cf2 std.Io: implement dir reading for BSDs 2025-12-23 22:15:09 -08:00
Andrew Kelley 94ef56ee26 std.Io.Dir: fix walking
* Make Io.Dir.Reader lower level, accepting a buffer.
* Make Io.Dir.Iterator higher level, requesting only one Entry with
  every call to `next`.
2025-12-23 22:15:09 -08:00
Andrew Kelley 7bc0166b7c std.Io: implement dirRead for Linux
unfortunately, Io.Dir.SelectiveWalker is copying the iterator which
has multiple problems
2025-12-23 22:15:09 -08:00
Andrew Kelley b042e93522 std: update tty config references in the build system 2025-12-23 22:15:09 -08:00
Andrew Kelley 7837d975dc std: save terminal escape stripping for later 2025-12-23 22:15:09 -08:00