aboutsummaryrefslogtreecommitdiff
path: root/lib/std/fs/File.zig
AgeCommit message (Collapse)Author
2025-07-21std.fs.File.Reader.sendFile: fix EndOfStream detectionAndrew Kelley
2025-07-21std.fs.File.Reader: fix sendFile logicAndrew Kelley
it wasn't accounting for both writer and reader buffering
2025-07-21std.fs.File.Reader: fix seek position logicAndrew Kelley
2025-07-21std.fs.File.Reader: only fcopyfile if size availableAndrew Kelley
2025-07-21objcopy: delete most of itAndrew Kelley
this code is not up to zig project standards tracked by #24522 oh, and fix not adjusting buffer seek position in std.fs.File.Reader
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-21std.fs.File.Reader: fix missed advance writer positionsAndrew Kelley
2025-07-14std.fs.File.Reader.seekTo: add missing int castAndrew Kelley
2025-07-11std.posix.send: should expect ConnectionRefusedAtlas Yu
Closes: #20219
2025-07-09std.fs.File.Writer: fix splat alias bugAndrew Kelley
same deal as previous commit
2025-07-07std.fs.File.Writer: implement positional writing for WindowsAndrew Kelley
2025-07-07fix 32-bit compilationAndrew Kelley
2025-07-07std.fs.File.Writer: implement positional writingAndrew Kelley
2025-07-07compiler: fix remaining build failuresAndrew Kelley
2025-07-07std.zip: work around deprecated APIAndrew Kelley
2025-07-07fix build runnerAndrew Kelley
2025-07-07update compiler source to new APIsAndrew Kelley
2025-07-07std.Build.Cache: write manifest without heap allocatingAndrew Kelley
Now that the buffered writing interface is not generic.
2025-07-07std.fs.File.Writer: fix drain implementationAndrew Kelley
it didn't account for data.len can no longer be zero
2025-07-07std.fmt: breaking API changesAndrew Kelley
added adapter to AnyWriter and GenericWriter to help bridge the gap between old and new API make std.testing.expectFmt work at compile-time std.fmt no longer has a dependency on std.unicode. Formatted printing was never properly unicode-aware. Now it no longer pretends to be. Breakage/deprecations: * std.fs.File.reader -> std.fs.File.deprecatedReader * std.fs.File.writer -> std.fs.File.deprecatedWriter * std.io.GenericReader -> std.io.Reader * std.io.GenericWriter -> std.io.Writer * std.io.AnyReader -> std.io.Reader * std.io.AnyWriter -> std.io.Writer * std.fmt.format -> std.fmt.deprecatedFormat * std.fmt.fmtSliceEscapeLower -> std.ascii.hexEscape * std.fmt.fmtSliceEscapeUpper -> std.ascii.hexEscape * std.fmt.fmtSliceHexLower -> {x} * std.fmt.fmtSliceHexUpper -> {X} * std.fmt.fmtIntSizeDec -> {B} * std.fmt.fmtIntSizeBin -> {Bi} * std.fmt.fmtDuration -> {D} * std.fmt.fmtDurationSigned -> {D} * {} -> {f} when there is a format method * format method signature - anytype -> *std.io.Writer - inferred error set -> error{WriteFailed} - options -> (deleted) * std.fmt.Formatted - now takes context type explicitly - no fmt string
2025-07-07std.io: deprecated Reader/Writer; introduce new APIAndrew Kelley
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-01-30std.fs.File: limit initial_cap according to max_bytes in readToEndAllocOptionsRui He
2024-11-27std.os.windows: Map PIPE_NOT_AVAILABLE from OpenFile() to error.NoDevice ↵Justin Braben
(#21938)
2024-10-31std.fs.File: Fix metadata error check on LinuxArchit Gupta
On Linux, File.metadata calls the statx syscall directly. As such, the return value is the error code. Previously, it handled the error with `posix.errno`, which when libc is linked, treats the return value as a value set to -1 if there is an error with the error code in errno. If libc wasn't linked, it would be handled correctly. In the Linux with libc linked case, this would cause the error result to always be treated as success (err val != -1), even when an error occurred.
2024-07-29std.fs: Rework to always use statx() instead of fstat()/fstatat() on Linux.Alex Rønne Petersen
statx() is strictly superior to stat() and friends. We can do this because the standard library declares Linux 4.19 to be the minimum version supported in std.Target. This is also necessary on riscv32 where there is only statx(). While here, I improved std.fs.File.metadata() to gather as much information as possible when calling statx() since that is the expectation from this particular API.
2024-07-29std: Stop supporting Linux/glibc versions older than declared in std.Target.Alex Rønne Petersen
2024-07-19std.c reorganizationAndrew Kelley
It is now composed of these main sections: * Declarations that are shared among all operating systems. * Declarations that have the same name, but different type signatures depending on the operating system. Often multiple operating systems share the same type signatures however. * Declarations that are specific to a single operating system. - These are imported one per line so you can see where they come from, protected by a comptime block to prevent accessing the wrong one. Closes #19352 by changing the convention to making types `void` and functions `{}`, so that it becomes possible to update `@hasDecl` sites to use `@TypeOf(f) != void` or `T != void`. Happily, this ended up removing some duplicate logic and update some bitrotted feature detection checks. A handful of types have been modified to gain namespacing and type safety. This is a breaking change. Oh, and the last usage of `usingnamespace` site is eliminated.
2024-06-05File.getOrEnableAnsiEscapeSupport: Do not attempt to set ↵Ryan Liptak
DISABLE_NEWLINE_AUTO_RETURN Follow up to #20172. Fixes #20188
2024-06-02Add `File.getOrEnableAnsiEscapeSupport` and use itRyan Liptak
On Windows, the console mode flag `ENABLE_VIRTUAL_TERMINAL_PROCESSING` determines whether or not ANSI escape codes are parsed/acted on. On the newer Windows Terminal, this flag is set by default, but on the older Windows Console, it is not set by default, but *can* be enabled (since Windows 10 RS1 from June 2016). The new `File.getOrEnableAnsiEscapeSupport` function will get the current status of ANSI escape code support, but will also attempt to enable `ENABLE_VIRTUAL_TERMINAL_PROCESSING` on Windows if necessary which will provide better/more consistent results for things like `std.Progress` and `std.io.tty`. This type of change was not done previously due to a mistaken assumption (on my part) that the console mode would persist after the run of a program. However, it turns out that the console mode is always reset to the default for each program run in a console session.
2024-06-02lib/std/fs/File: enable VT seq support for Windows ConsoleGarfield Lee
* Newer versions of Windows added VT seq support not only in Windows Terminal, but also in the old-fashioned Windows Console (standalone conhost.exe), though not enabled by default. * Try setting the newer console mode flags provides better experience for Windows Console users. Co-authored-by: Kexy Biscuit <kexybiscuit@biscuitt.in>
2024-04-28std.posix.iovec: use .base and .len instead of .iov_base and .iov_lenNameless
2024-03-19fix compilation failures found by CIAndrew Kelley
2024-03-19extract std.posix from std.osAndrew Kelley
closes #5019
2024-02-24Fix handling of Windows (WTF-16) and WASI (UTF-8) pathsRyan Liptak
Windows paths now use WTF-16 <-> WTF-8 conversion everywhere, which is lossless. Previously, conversion of ill-formed UTF-16 paths would either fail or invoke illegal behavior. WASI paths must be valid UTF-8, and the relevant function calls have been updated to handle the possibility of failure due to paths not being encoded/encodable as valid UTF-8. Closes #18694 Closes #1774 Closes #2565
2024-02-14std.os.windows.OpenFile: add missing errorAndrew Kelley
Encountered in a recent CI run on an aarch64-windows dev kit. Pretty sure I disabled the virus scanner but it looks like it turned itself back on with a Windows Update. Rather than marking the new error code as unreachable in the places where it is unexpected, this commit makes it return `error.Unexpected`.
2024-02-11some API work on std.c, std.os, std.os.wasiAndrew Kelley
* std.c: consolidate some definitions, making them share code. For example, freebsd, dragonfly, and openbsd can all share the same `pthread_mutex_t` definition. * add type safety to std.c.O - this caught a bug where mode flags were incorrectly passed as the open flags. * 3 fewer uses of usingnamespace keyword * as per convention, remove purposeless field prefixes from struct field names even if they have those prefixes in the corresponding C code. * fix incorrect wasi libc Stat definition * remove C definitions from incorrectly being in std.os.wasi * make std.os.wasi definitions type safe * go through wasi native APIs even when linking libc because the libc APIs are problematic and wasteful * don't expose WASI definitions in std.posix * remove std.os.wasi.rights_t.ALL: this is a footgun. should it be all future rights too? or only all current rights known? both are the wrong answer.
2024-02-01remove std.io.ModeVeikka Tuominen
2023-12-22Merge pull request #18326 from squeek502/stat-symlinkVeikka Tuominen
`File.stat`: Support detection of `Kind.sym_link` on Windows
2023-12-20Fix `Stat.ctime` docs, and correct its value on WindowsRyan Liptak
ctime is last file status/metadata change, not creation time. Note that this mistake was not made in the `File.metadata`/`File.Metadata` implementation, which allows getting the actual creation time. Closes #18290
2023-12-19File.stat: Support detection of Kind.sym_link on WindowsRyan Liptak
Requires an extra NtQueryInformationFile call when FILE_ATTRIBUTE_REPARSE_POINT is set to determine if it's actually a symlink or some other kind of reparse point (https://learn.microsoft.com/en-us/windows/win32/fileio/reparse-point-tags). This is something that `File.Metadata.kind` was already doing, so the same technique is used in `stat`. Also, replace the std.os.windows.DeviceIoControl call in `metadata` with NtQueryInformationFile (NtQueryInformationFile is what gets called during kernel32.GetFileInformationByHandleEx with FileAttributeTagInfo, verified using NtTrace).
2023-11-22std.fs.File: flatten structAndrew Kelley