aboutsummaryrefslogtreecommitdiff
path: root/lib/std/fs/Dir.zig
AgeCommit message (Collapse)Author
2025-11-20system specific errnorpkak
2025-11-20update deprecated ArrayListUnmanaged usage (#25958)Benjamin Jurk
2025-11-15Merge pull request #25539 from squeek502/windows-readlinkwRyan Liptak
windows: Make readLinkW APIs output WTF-16, reduce stack usage of callers
2025-11-15windows: Make readLinkW APIs output WTF-16, reduce stack usage of callersRyan Liptak
- Affects the following functions: + `std.fs.Dir.readLinkW` + `std.os.windows.ReadLink` + `std.os.windows.ntToWin32Namespace` + `std.posix.readlinkW` + `std.posix.readlinkatW` Each of these functions (except `ntToWin32Namespace`) took WTF-16 as input and would output WTF-8, which makes optimal buffer re-use difficult at callsites and could force unnecessary WTF-16 <-> WTF-8 conversion during an intermediate step. The functions have been updated to output WTF-16, and also allow for the path and the output to re-use the same buffer (i.e. in-place modification), which can reduce the stack usage at callsites. For example, all of `std.fs.Dir.readLink`/`readLinkZ`/`std.posix.readlink`/`readlinkZ`/`readlinkat`/`readlinkatZ` have had their stack usage reduced by one PathSpace struct (64 KiB) when targeting Windows. The new `ntToWin32Namespace` takes an output buffer and returns a slice from that instead of returning a PathSpace, which is necessary to make the above possible.
2025-11-15fix: add specific error set for SelectiveWalker iterator functionSam Bossley
2025-11-14represent Mac Catalyst as aarch64-maccatalyst-none rather than ↵Alex Rønne Petersen
aarch64-ios-macabi Apple's own headers and tbd files prefer to think of Mac Catalyst as a distinct OS target. Earlier, when DriverKit support was added to LLVM, it was represented a distinct OS. So why Apple decided to only represent Mac Catalyst as an ABI in the target triple is beyond me. But this isn't the first time they've ignored established target triple norms (see: armv7k and aarch64_32) and it probably won't be the last. While doing this, I also audited all Darwin OS prongs throughout the codebase and made sure they cover all the tags.
2025-10-29std.Io.Threaded: add ioBasic which disables networkingAndrew Kelley
2025-10-29std.Io.Threaded: implement dirOpenDirAndrew Kelley
2025-10-29std.Io: add dirMakePath and dirMakeOpenPathAndrew Kelley
2025-10-29std.Io.Threaded: implement dirOpenFile for WindowsAndrew Kelley
2025-10-29std.Io.Threaded: implement dirCreateFile for WindowsAndrew Kelley
2025-10-29std.Io.Threaded: implement dirStatPath for WindowsAndrew Kelley
2025-10-29std: fix compilation errors on WindowsAndrew Kelley
2025-10-29std: move some windows path checking logicAndrew Kelley
2025-10-29std.fs: use BadPathName rather than InvalidWtf8 on WindowsAndrew Kelley
2025-10-29std.Io: add dirOpenDir and WASI implAndrew Kelley
2025-10-29std.Io.Threaded: implement dirOpenFile for WASIAndrew Kelley
2025-10-29std.Io.Threaded: implement dirCreateFile for WASIAndrew Kelley
2025-10-29std.Io: add dirAccessAndrew Kelley
2025-10-29fix miscellaneous compilation errorsAndrew Kelley
- ILSEQ -> error.BadPathName - implement dirStatPath for WASI
2025-10-29fix miscellaneous compilation failuresAndrew Kelley
2025-10-29std.Io: implement dirOpenFileAndrew Kelley
2025-10-29std.Io: implement dirStatPathAndrew Kelley
2025-10-29std: updating to std.Io interfaceAndrew Kelley
got the build runner compiling
2025-10-29std.Io: extract Dir to separate fileAndrew Kelley
2025-10-27remove all Oracle Solaris supportAlex Rønne Petersen
There is no straightforward way for the Zig team to access the Solaris system headers; to do this, one has to create an Oracle account, accept their EULA to download the installer ISO, and finally install it on a machine or VM. We do not have to jump through hoops like this for any other OS that we support, and no one on the team has expressed willingness to do it. As a result, we cannot audit any Solaris contributions to std.c or other similarly sensitive parts of the standard library. The best we would be able to do is assume that Solaris and illumos are 100% compatible with no way to verify that assumption. But at that point, the solaris and illumos OS tags would be functionally identical anyway. For Solaris especially, any contributions that involve APIs introduced after the OS was made closed-source would also be inherently more risky than equivalent contributions for other proprietary OSs due to the case of Google LLC v. Oracle America, Inc., wherein Oracle clearly demonstrated its willingness to pursue legal action against entities that merely copy API declarations. Finally, Oracle laid off most of the Solaris team in 2017; the OS has been in maintenance mode since, presumably to be retired completely sometime in the 2030s. For these reasons, this commit removes all Oracle Solaris support. Anyone who still wishes to use Zig on Solaris can try their luck by simply using illumos instead of solaris in target triples - chances are it'll work. But there will be no effort from the Zig team to support this use case; we recommend that people move to illumos instead.
2025-10-10replaced https://simonsapin.github.io/wtf-8/ with https://wtf-8.codeberg.page/usebeforefree
2025-10-10Dir.realpathW: remove redundant buffer/copyRyan Liptak
This same change was applied in 69007f096177143086e28da0dc1a0eff4efcc52c but accidentally reverted in 7bf740ee718f4b6109cd9fe7014d1784d48ada48
2025-10-08Deprecate old realpathW correctlyMichael Pfaff
- Rename modified `realpathW` to `realpathW2` - Re-add original `realpathW` - Add deprecation notice to `realpathW`
2025-10-08Reuse pathname_w buffer as out_buffer when calling realpathWMichael Pfaff
2025-10-08Improve documentation on Dir.realpathWMichael Pfaff
2025-10-08Return WTF16LE encoded path from realpathWMichael Pfaff
2025-10-03Add depth function to `Walker.Entry`Ryan Liptak
This enables depth-related use cases without any dependency on the Walker's internal stack which doesn't always pertain to the actual depth of the current entry (i.e. recursing into a directory immediately affects the stack).
2025-10-03feat: Reintroduce depthHenry Kupty
Some decision-making might depend on the level of the traversal, so it makes sense to expose depth here since it's stable, and not in the automatic walker where it's not.
2025-10-03Add SelectiveWalker/walkSelectively and implement Walker in terms of itRyan Liptak
This is a breaking change, since the fields of Walker have changed. The function APIs are unchanged, though.
2025-08-30rework std.Io.Writer.Allocating to support runtime-known alignmentAndrew Kelley
Also, breaking API changes to: * std.fs.Dir.readFileAlloc * std.fs.Dir.readFileAllocOptions
2025-08-23std.fs.Dir: fix updateFile() to flush the file before updating its timesAlex Rønne Petersen
AtomicFile.finish() calls flush() which renders any previous updateTimes() calls useless. Regression introduced in f2a3ac7c0534a74ee544fdf6ef9d2176a8d62389. Closes #24927.
2025-07-21std.fs.File: delete writeFileAll and friendsAndrew Kelley
please use File.Writer for these use cases also breaking API changes to std.fs.AtomicFile
2025-07-11Remove numerous things deprecated during the 0.14 release cycleLinus Groh
Basically everything that has a direct replacement or no uses left. Notable omissions: - std.ArrayHashMap: Too much fallout, needs a separate cleanup. - std.debug.runtime_safety: Too much fallout. - std.heap.GeneralPurposeAllocator: Lots of references to it remain, not a simple find and replace as "debug allocator" is not equivalent to "general purpose allocator". - std.io.Reader: Is being reworked at the moment. - std.unicode.utf8Decode(): No replacement, needs a new API first. - Manifest backwards compat options: Removal would break test data used by TestFetchBuilder. - panic handler needs to be a namespace: Many tests still rely on it being a function, needs a separate cleanup.
2025-06-19Build: add install commands to `--verbose` outputJacob Young
2025-06-05std.fs.Dir: haiku fixesElaine Gibson
2025-06-05std.fs.Dir.Iterator: Address a couple of alignment TODOs.Alex Rønne Petersen
2025-04-26Calculate WTF-8 length before converting instead of converting into an ↵Michael Pfaff
intermediate buffer on the stack
2025-04-14Merge pull request #23268 from chrboesch/i19875Chris Boesch
std.posix: Added 'error.ProcessNotFound' where necessary
2025-04-13std: eradicate u29 and embrace std.mem.AlignmentAndrew Kelley
2025-03-24lib/std: PermissionDenied/AccessDenied cleanup and falloutPat Tullmann
This PR consistently maps .ACCES into AccessDenied and .PERM into PermissionDenied. AccessDenied is returned if the file mode bit (user/group/other rwx bits) disallow access (errno was `EACCES`). PermissionDenied is returned if something else denies access (errno was `EPERM`) (immutable bit, SELinux, capabilities, etc). This somewhat subtle distinction is a POSIX thing. Most of the change is updating std.posix Error Sets to contain both errors, and then propagating the pair up through caller Error Sets. Fixes #16782
2025-03-24windows: Use AccessDenied for ACCESS_DENIED on WindowsPat Tullmann
Windows defines an `ACCESS_DENIED` error code. There is no PERMISSION_DENIED (or its equivalent) which seems to only exist on POSIX systems. Fix a couple Windows calls code to return `error.AccessDenied` for `ACCESS_DENIED` and to stop mapping AccessDenied into PermissionDenied.
2025-02-17std.Target: Remove functions that just wrap component functions.Alex Rønne Petersen
Functions like isMinGW() and isGnuLibC() have a good reason to exist: They look at multiple components of the target. But functions like isWasm(), isDarwin(), isGnu(), etc only exist to save 4-8 characters. I don't think this is a good enough reason to keep them, especially given that: * It's not immediately obvious to a reader whether target.isDarwin() means the same thing as target.os.tag.isDarwin() precisely because isMinGW() and similar functions *do* look at multiple components. * It's not clear where we would draw the line. The logical conclusion before this commit would be to also wrap Arch.isX86(), Os.Tag.isSolarish(), Abi.isOpenHarmony(), etc... this obviously quickly gets out of hand. * It's nice to just have a single correct way of doing something.
2025-02-10std.ArrayList: popOrNull() -> pop() [v2] (#22720)Meghan Denny
2025-02-09wasi: fix wasm-wasi-musl constantsPat Tullmann
Zig's copy of the `SYMLINK_{NO,}FOLLOW` constants from wasi-musl was wrong, as were the `IFIFO` and `IFSOCK` file type flags. Fix these up, and add comments pointing to exactly where they come from (as the wasi-musl source has lots of unused, different definitions of these constants). Add tests for the Zig convention that WASM preopen 3 is the current working directory. This is true for WASM with or without libc. Enable several fs and posix tests that are now passing (not necessarily because of this change) on wasm targets. Fixes #20890.