664 Commits

Author SHA1 Message Date
Andrew Kelley bd05d13d5f std: make file locking tests use io not threads
This will allow the tests to also run in single-threaded evented mode.
2026-04-01 02:54:25 -07:00
Alex Rønne Petersen f40eb50157 std.fs.test: disable '.' and '..' in Dir functions test on *-windows
https://codeberg.org/ziglang/zig/issues/31561
2026-03-27 02:24:23 +01:00
Alex Rønne Petersen 36b28050f4 std.fs.test: disable AtomicFile test on windows
https://codeberg.org/ziglang/zig/issues/31389
2026-03-27 02:24:21 +01:00
Matthew Lugg 64f1c27332 compiler,std: fix never-mutated local variables 2026-03-15 18:22:13 +00:00
samy007 a5dd6444c3 Add test for calling statFile on a symlink 2026-03-10 00:10:49 -07:00
DivergentClouds 416ef983c4 add test for Lock.none 2026-03-10 00:10:48 -07:00
Andrew Kelley b191e50be5 std.Thread: remove ResetEvent and WaitGroup
* std.Thread.ResetEvent -> Io.Event
* std.Thread.WaitGroup -> Io.Group
2026-02-02 00:09:48 -08:00
Andrew Kelley b1d1806fef std.process: currentDir -> currentPath
In Zig standard library, Dir means an open directory handle. path
represents a file system identifier string. This function is better
named after "current path" than "current dir". "get" and "working" are
superfluous.
2026-01-29 18:47:58 -08:00
Andrew Kelley 649aaf4814 std: migrate getcwd to Io
progress towards #30150
2026-01-29 18:40:55 -08:00
Alex Rønne Petersen 9f33c339c7 std.fs.test: fix file operations on directories on NetBSD
As noted earlier in this test, reading directories does not fail on NetBSD.
2026-01-21 16:42:02 +01:00
Alex Rønne Petersen a3ea3bd31d std: NetBSD doesn't have a reliable F_GETPATH
It can fail arbitrarily with ENOENT if the kernel happens to not have the FD in
its name cache. That makes it useless for our purposes.

closes https://codeberg.org/ziglang/zig/issues/30843
2026-01-21 16:41:51 +01:00
Michael Dusan 32f977a4b7 std.fs.test: fix tests using Dir.realPath
* add fn isRealPathSupported
* incorporate into tests that depends on Dir.realPath
2026-01-21 16:41:37 +01:00
Andrew Kelley c4df980ac2 std.fs: fix test cases regarding error.IsDir on WASI
why were we testing for shitty behavior?
2026-01-15 14:18:20 -08:00
Ryan Liptak 4cf7dc22fa Expand the errors that act as "sym links can't be created" on Windows
Previously, the errors that are now mapped to AccessDenied, PermissionDenied, and FileSystem were all mapped to AccessDenied.
2026-01-11 02:08:18 -08:00
Ryan Liptak b4831403c9 fileRead functions: handle INVALID_FUNCTION on Windows and map it to error.IsDir
INVALID_FUNCTION may be possible in other scenarios as well, but it is verifiably returned when the handle refers to a directory.
2026-01-11 02:08:18 -08:00
Alex Rønne Petersen d1be8b138e Merge pull request 'enable x86_64-openbsd CI' (#30733) from alexrp/zig:openbsd-ci into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30733
2026-01-08 12:35:11 +01:00
Andrew Kelley 7248b4a4e4 std.fs: deprecate base64 APIs
100% of std.fs is now deprecated.
2026-01-07 17:33:06 -08:00
Andrew Kelley c44e12dcd3 std: find a better home for the "preopens" concept 2026-01-07 17:33:06 -08:00
Andrew Kelley ee574f665c std.Io.Dir: introduce renamePreserve and use it in File.Atomic.link
breaking change: the error for renaming over a non-empty directory now
returns error.DirNotEmpty rather than error.PathAlreadyExists.
2026-01-07 11:03:37 -08:00
Andrew Kelley 1eddc1737c std: add test coverage for Io.File.Atomic.link 2026-01-07 11:03:37 -08:00
Andrew Kelley 1f1381a866 update API usage of std.crypto.random to io.random 2026-01-07 11:03:36 -08:00
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 1070c2a71a rename env_map to environ_map
For naming consistency with `std.process.Environ.Map`.
2026-01-04 00:27:09 -08:00
Andrew Kelley 60447ea97c std: fix windows compilation errors 2026-01-04 00:27:08 -08:00
Andrew Kelley 08447ca47e std.fs.path: make relative a pure function
Instead of querying the operating system for current working directory
and environment variables, this function now accepts those things as
inputs.
2026-01-04 00:27:08 -08:00
Andrew Kelley e956948f99 std: remove fs.getAppDataDir with no replacement
This API is a bit too opinionated for the Zig standard library.
Applications should contain this logic instead.
2025-12-30 16:21:25 -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