75 Commits

Author SHA1 Message Date
Andrew Kelley 50f96d2ca1 std.Io.Dir: add type checking for those two functions 2026-04-19 10:08:23 -07:00
Lukas Lalinsky 52e06ce4f6 std.Io.Dir: fix incorrect return types in setFileOwner and setTimestampsNow
`setFileOwner` declared `SetOwnerError!void` but its vtable method
returns the wider `SetFileOwnerError!void` (adds `NameTooLong` and
`BadPathName`), so any call through the wrapper fails to compile.

`setTimestampsNow` dispatched to `io.vtable.fileSetTimestamps` with
`(Dir, []const u8, Dir.SetTimestampsOptions)`, but that vtable entry
takes `(File, File.SetTimestampsOptions)`. The intended target is
`dirSetTimestamps`, whose signature matches the call site.
2026-04-19 10:07:44 -07:00
Andrew Kelley 2e4482cd14 std.Io.Dir: add resolve_beneath flag and implement for freebsd,macos 2026-03-27 01:23:04 -07:00
Andrew Kelley 6f467e436d std.Io: move File.CreateFlags to Dir.CreateFileOptions
for naming consistency.

same thing with File.OpenFlags -> Dir.OpenFileFlags
2026-03-27 01:23:04 -07:00
Nathan Bourgeois 2037dba90f std.posix: Minimal set to build an Io on PSP 2026-03-21 06:34:45 -04:00
Matthew Lugg 8eefe86939 std: remove default values from ArrayList
These were deprecated in the 0.14.0 release cycle almost a year ago, so
they can definitely be deleted now.
2026-03-10 10:26:08 +00:00
Andrew Kelley 18c6abc0ba std: finish moving os.windows.ReadLink logic to Io.Threaded
- remove error.SharingViolation from all error sets since it has the
  same meaning as FileBusy
- add error.FileBusy to CreateFileAtomicError and ReadLinkError
- update dirReadLinkWindows to use NtCreateFile and NtFsControlFile and
  integrate with cancelation properly.
- move windows CTL_CODE constants to the proper namespace
- delete os.windows.ReadLink
2026-01-28 17:02:17 -08:00
Andrew Kelley 1badb2a840 std.Io.Threaded: dirCreateFileWindows uses NtCreateFile directly 2026-01-22 18:08:13 -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 81a35a86ea std.Io: introduce random and randomSecure
and use a thread-local CSPRNG for the former.
2026-01-07 11:03:36 -08:00
Andrew Kelley 81bfd28974 std.Io.Dir: rework atomic file 2026-01-05 20:28:58 -08:00
Andrew Kelley d6a1e73142 std: start wrangling environment variables and process args
this commit is unfinished. It marks a spot where I wanted to start
moving child process stuff below the std.Io.VTable
2026-01-04 00:27:07 -08: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
nyx-xyn f2f474fc78 std.Io.Dir: pass io to Walker.leave 2025-12-29 00:36:57 +01:00
Andrew Kelley a7c9d11b28 std.Io: make file access time optional
Some filesystems, such as ZFS, do not report atime. It's pretty useless
in general, so make it an optional field in File.Stat.

Also take the opportunity to make setting timestamps API more flexible
and match the APIs widely available, which have UTIME_OMIT and UTIME_NOW
constants that can be independently set for both fields.

This is needed to handle smoothly the case when atime is null.
2025-12-27 10:40:24 -08:00
Ryan Liptak e442a0ecc2 Dir.readFile/readFileAlloc: take advantage of .allow_directory = false on Windows
Since we know the read will fail for directories, we can take advantage
of Windows being able to fail with IsDir during open to avoid needing to
wait until the read to find out about the directory-ness of the file.
2025-12-23 22:15:11 -08:00
Ryan Liptak ad08117e9d Fix sizing of buffer/reservation size for dirReadWindows 2025-12-23 22:15:11 -08:00
Andrew Kelley 99f25bfc23 std.Io: implement directory reading for WASI 2025-12-23 22:15:11 -08: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 6aa31cedb7 std.Io.Dir.Reader: fix min_buffer_len on 32-bit linux
dirents64 still uses 8 byte alignment on 32-bit systems
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
Ryan Liptak 3431f45031 std: Enough fixes to get things compiling on Windows 2025-12-23 22:15:11 -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 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 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
Andrew Kelley a5b719e9eb compiler: fix build failures from std.Io-fs 2025-12-23 22:15:10 -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 16bd2e137e compiler: fix most compilation errors from std.fs changes 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 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 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 78d262d96e std: WIP: debug-level stderr writing 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 bee8005fe6 std.heap.DebugAllocator: never detect TTY config
instead, allow the user to set it as a field.

this fixes a bug where leak printing and error printing would run tty
config detection for stderr, and then emit a log, which is not necessary
going to print to stderr.

however, the nice defaults are gone; the user must explicitly assign the
tty_config field during initialization or else the logging will not have
color.

related: https://github.com/ziglang/zig/issues/24510
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 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 950d18ef69 update all access() to access(io) 2025-12-23 22:15:08 -08:00
Andrew Kelley 7f5bb118d4 std.Io: make all the close functions batched 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