Commit graph

253 commits

Author SHA1 Message Date
Alex Rønne Petersen
9db475de70
std.fs.test: skip executablePath and openExecutable on OpenBSD
processExecutablePath() is unsupported.
2026-01-07 05:06:12 +01:00
Andrew Kelley
4365b0df88 std.Io.Threaded: add File.hardLink 2026-01-05 20:28:58 -08:00
Andrew Kelley
60447ea97c std: fix windows compilation errors 2026-01-04 00:27:08 -08:00
Michael Dusan
4b26c49076
dragonfly: make test lib/std/std.zig pass 2025-12-29 22:29:56 -05:00
Michael Dusan
09f06082f0
openbsd: make test lib/std/std.zig pass
* According to OpenBSD's getdents docs indicate the buffer must be
  greater or or equal to the block size associated with the file and to
  refer to stat(2).
* Use S_BLKSIZE, which is 512, instead of @sizeOf(std.c.dirent), which is 280.
* Oddly the other BSDs are not this picky.
2025-12-29 21:40:02 -05:00
Andrew Kelley
a8088306f6 std: rename other Dir "make" functions to "create" 2025-12-23 22:15:11 -08:00
Andrew Kelley
6e0c7ed865 std: rename makeDir to createDir for consistency with createFile 2025-12-23 22:15:11 -08:00
Andrew Kelley
6cfd2df695 don't skip test for closed issue 2025-12-23 22:15:11 -08:00
Andrew Kelley
bf81666beb std.fs.test: don't try to test nonexistent API 2025-12-23 22:15:11 -08:00
Andrew Kelley
d060cb8cd6 std: fix test "max file name component lengths" 2025-12-23 22:15:11 -08:00
Andrew Kelley
002d444964 std: fix Io.Dir.min_buffer_len on Linux 2025-12-23 22:15:11 -08:00
Andrew Kelley
018e34271f std.fs.test: fix rebase conflicts 2025-12-23 22:15:11 -08:00
Ryan Liptak
b6cde02322 fs tests: Remove references to readLinkW which no longer exists 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
6f00157e1e std: fix "open smoke test" by passing allow_directory option 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
b4bfd501ae std: move some tests from posix to fs 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
16bd2e137e compiler: fix most compilation errors from std.fs changes 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
5b436d2c51 build_runner compiling again 2025-12-23 22:15:08 -08:00
Andrew Kelley
4a53e5b0b4 fix a handful of compilation errors related to std.fs migration 2025-12-23 22:15:08 -08:00
Andrew Kelley
ebdbbd20ac update makeDir() sites to specify permissions 2025-12-23 22:15:08 -08:00
Andrew Kelley
1dcfc8787e update all readFileAlloc() to accept Io instance 2025-12-23 22:15:08 -08:00
Andrew Kelley
4be8be1d2b update all rename() to rename(io) 2025-12-23 22:15:08 -08:00
Andrew Kelley
4218344dd3 std.Build.Cache: remove readSmallFile and writeSmallFile
These were to support optimizations involving detecting when to avoid
calling into LLD, which are no longer implemented.
2025-12-23 22:15:08 -08:00
Andrew Kelley
950d18ef69 update all access() to access(io) 2025-12-23 22:15:08 -08:00
Andrew Kelley
9ccd68de0b std: move abort and exit from posix into process
and delete the unit tests that called fork()

no forking allowed in the std lib, including unit tests, except to implement child process spawning.
2025-12-23 22:15:08 -08:00
Andrew Kelley
6f46570958 link.MachO: update parallel hasher to std.Io 2025-12-23 22:15:08 -08:00
Andrew Kelley
9f4d40b1f9 update all stat() to stat(io) 2025-12-23 22:15:08 -08:00
Andrew Kelley
264d714321 update all openDir() sites to accept io instance 2025-12-23 22:15:08 -08:00
Andrew Kelley
f53248a409 update all std.fs.cwd() to std.Io.Dir.cwd() 2025-12-23 22:15:08 -08:00
Andrew Kelley
9169983159 std.fs: migrate most of the API elsewhere 2025-12-23 22:15:08 -08:00
Andrew Kelley
877032ec6a std: reorganize realpath and process executable APIs 2025-12-23 22:15:08 -08:00
Andrew Kelley
8328de24f1 update all occurrences of openFile to receive an io instance 2025-12-23 22:15:08 -08:00
Andrew Kelley
dd1d15b72a update all occurrences of std.fs.Dir to std.Io.Dir 2025-12-23 22:15:08 -08:00
Andrew Kelley
3204fb7569 update all occurrences of std.fs.File to std.Io.File 2025-12-23 22:15:07 -08:00
Andrew Kelley
aafddc2ea1 update all occurrences of close() to close(io) 2025-12-23 22:15:07 -08:00
Andrew Kelley
d1d2c37af2 std: all Dir functions moved to std.Io 2025-12-23 22:15:07 -08:00