aboutsummaryrefslogtreecommitdiff
path: root/lib/std/fs
AgeCommit message (Collapse)Author
2020-09-24writevLoris Cro
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24writeLoris Cro
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24preadvLoris Cro
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24preadLoris Cro
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24readvLoris Cro
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24readLoris Cro
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-17Add rename to std.fs APIRyan Liptak
- Moves fs.rename functions to fs.renameAbsolute to match other functions outside of fs.Dir - Adds fs.Dir.rename that takes two paths relative to the given Dir - Adds fs.rename that takes two separate Dir's that the given paths are relative to (for renaming across directories without having to make the second path relative to a single directory) - Fixes FileNotFound error return in std.os.windows.MoveFileExW - Returns error.RenameAcrossMountPoints from renameatW + Matches the RenameAcrossMountPoints error return in renameatWasi/renameatZ
2020-09-10std.fs.File: fix typo in writeFileAllAndrew Kelley
2020-09-10fs/file.zig: Update reader to use type aliasChristian Wesselhoeft
This is a minor cosmetic change which updates `reader` and `inStream` to match `writer` and `outStream` below.
2020-09-04std: Minor changes to the fs moduleLemonBoy
* Add a size_hint parameter to the read{toEnd,File}AllocOptions fns * Rename readAllAlloc{,Options} to readToEndAlloc{,Options} as they don't rewind the file before reading * Fix missing rewind in test case
2020-09-02std: Don't trust stat() size in readAllAlloc fnsLemonBoy
Some files such as the ones in /proc report a st_size of zero, try to read the file anyway if we hit that case.
2020-08-30handle lack of privilege to create symbolic links on windowsSahnvour
2020-08-24std: use O_NOCTTY flagdaurnimator
2020-08-20add license header to all std lib filesAndrew Kelley
add SPDX license identifier copyright ownership is zig contributors
2020-08-13Add std.os.getFdPath and std.fs.Dir.realpathJakub Konka
`std.os.getFdPath` is very platform-specific and can be used to query the OS for a canonical path to a file handle. Currently supported hosts are Linux, macOS and Windows. `std.fs.Dir.realpath` (and null-terminated, plus WTF16 versions) are similar to `std.os.realpath`, however, they resolve a path wrt to this `Dir` instance. If the input pathname argument turns out to be an absolute path, this function reverts to calling `realpath` on that pathname completely ignoring this `Dir`.
2020-08-11copy_file_range linux syscall (#6010)Maciej Walczak
2020-07-31Move delete file logic into windows.DeleteFile fnJakub Konka
This way, we can remove more `kernel32` calls such as `RemoveDirectoryW` or `DeleteFileW`, and use `std.os.windows.DeleteFile` instead which is purely NT-based.
2020-07-31Remove CreateDirectoryW and CreateFileW callsJakub Konka
Replace them with `std.os.windows.OpenFile` instead. To allow creation/opening of directories, `std.os.windows.OpenFileOptions` now features a `.expect_dir: bool` member which is meant to emualate POSIX's `O_DIRECTORY` flag.
2020-07-22Add missing cross-platform Dir.readLink fnsJakub Konka
2020-07-22Ensure Dir.deleteTree does not dereference symlinksJakub Konka
Otherwise, the behaviour can lead to unexpected results, resulting in removing an entire tree that's not necessarily under the root. Furthermore, this change is needed if are to properly handle dir symlinks on Windows. Without explicitly requiring that a directory or file is opened with `FILE_OPEN_REPARSE_POINT`, Windows automatically dereferences all symlinks along the way. This commit adds another option to `OpenDirOptions`, namely `.no_follow`, which defaults to `false` and can be used to specifically open a directory symlink on Windows or call `openat` with `O_NOFOLLOW` flag in POSIX.
2020-07-22Move symlink to fs.symlinkAbsolute with SymlinkFlagsJakub Konka
This way `std.fs.symlinkAbsolute` becomes cross-platform and we can legally include `SymlinkFlags` as an argument that's only used on Windows. Also, now `std.os.symlink` generates a compile error on Windows with a message to instead use `std.os.windows.CreateSymbolicLink`. Finally, this PR also reshuffles the tests between `std.os.test` and `std.fs.test`.
2020-07-12Fix incorrect continue condition in PreopeonListJakub Konka
Also, check for overflow on incremented file descriptors. Previously, we'd trigger a panic if we exceeded the `fd_t` resolution. Now, instead, we throw an `error.Overflow` to signal that there can be no more file descriptors available from the runtime. This way we give the user the ability to still be able to check if their desired preopen exists in the list or not.
2020-07-11run zig fmt on std lib and self hostedVexu
2020-07-07Merge pull request #5755 from kubkon/dir-iter-testsAndrew Kelley
[libstd]: add Dir.Iterator tests
2020-07-04std.mem.dupe is deprecated, move all references in stdjoachimschmidt557
Replaced all occurences of std.mem.dupe in stdlib with Allocator.dupe/std.mem.dupeZ -> Allocator.dupeZ
2020-07-02Update lib/std/fs/test.zigJakub Konka
Co-authored-by: Joachim Schmidt <joachim.schmidt557@outlook.com>
2020-07-02Fix memory corruption in Dir.Iterator testJakub Konka
2020-07-02Add Dir.Iterator testsJakub Konka
This commit adds some `std.fs.Dir.Iterator` tests.
2020-07-01Merge pull request #5717 from squeek502/fs-dir-file-opsAndrew Kelley
Add tests for using file operations on directories
2020-06-28Disable wasi 'readFileAlloc on a directory' assertion for nowRyan Liptak
2020-06-27Move fs-specific tests from os/test.zig to fs/test.zigRyan Liptak
The moved tests do not use `std.os` directly and instead use `std.fs` functions, so it makes more sense for them to be in `fs/test.zig`
2020-06-26Add tests for using file operations on directoriesRyan Liptak
2020-06-25Add tests for using directory operations on filesRyan Liptak
2020-06-23Remove some leftover debugging checksJakub Konka
2020-06-23Refactor PreopenList.find()Jakub Konka
This commit generalizes `std.fs.wasi.PreopenList.find(...)` allowing search by `std.fs.wasi.PreopenType` union type rather than by dir name. In the future releases of WASI, it is expected to have more preopen types (or capabilities) than just directories. This commit aligns itself with that vision. This is a potentially breaking change. However, since `std.fs.wasi.PreopenList` wasn't made part of any Zig release yet, I think we should be OK to introduce those changes without pointing to any deprecations.
2020-06-22Add std.fs.File.readAllAlloc testsJakub Konka
This commit adds some unit tests for `std.fs.File.readAllAlloc` function. It also updates the docs of `Reader.readNoEof` which were outdated, and swaps `inStream()` for `reader()` in `File.readAllAlloc` with the former being deprecated.
2020-06-20implement new stat functionality for WASIAndrew Kelley
2020-06-20rework zig fmt to use less syscalls and open fdsAndrew Kelley
* `std.fs.Dir.Entry.Kind` is moved to `std.fs.File.Kind` * `std.fs.File.Stat` gains the `kind` field, so performing a stat() on a File now tells what kind of file it is. On Windows this only will distinguish between directories and files. * rework zig fmt logic so that in the case of opening a file and discovering it to be a directory, it closes the file descriptor before re-opening it with O_DIRECTORY, using fewer simultaneous open file descriptors when walking a directory tree. * rework zig fmt logic so that it pays attention to the kind of directory entries, and when it sees a sub-directory it attempts to open it as a directory rather than a file, reducing the number of open() syscalls when walking a directory tree.
2020-06-18rework zig fmt to only make one allocationAndrew Kelley
taking advantage of the fstat size
2020-06-18Fix fs.File.mode() not returning mode_t on windowsCassidy Dingenskirchen
2020-06-11Add unit test for std.fs.wasi.PreopenListJakub Konka
2020-06-11Add custom format method for Preopen structJakub Konka
2020-06-09Support Reader for InStreamJonathan Marler
2020-06-09fix memory errorsJonathan Marler
2020-06-08support Writer instead of OutStreamJonathan Marler
Start implementing https://github.com/ziglang/zig/issues/4917 which is to rename instream/outstream to reader/writer. This first change allows code to use Writer/writer instead of OutStream/outStream, but still maintains the old outstream names with "Deprecated" comments.
2020-05-29Prefer Files to paths in std.debug. Additionally [breaking] add a flags ↵Jonathan S
parameter to openSelfExe and stop exporting openElfDebugInfo. This should save a call to readlink in openSelfDebugInfo and support executables in overlong paths on Linux.
2020-05-25improvements to self-hosted cache hash systemAndrew Kelley
* change miscellaneous things to more idiomatic zig style * change the digest length to 24 bytes instead of 48. This is still 70 more bits than UUIDs. For an analysis of probability of collisions, see: https://en.wikipedia.org/wiki/Universally_unique_identifier#Collisions * fix the API having the possibility of mismatched allocators * fix some error paths to behave properly * modify the guarantees about when file contents are loaded for input files * pwrite instead of seek + write * implement isProblematicTimestamp * fix tests with regards to a working isProblematicTimestamp function. this requires sleeping until the current timestamp becomes unproblematic. * introduce std.fs.File.INode, a cross platform type abstraction so that cache hash implementation does not need to reach into std.os.
2020-05-24(breaking) std.time fixups and API changesAndrew Kelley
Remove the constants that assume a base unit in favor of explicit x_per_y constants. nanosecond calendar timestamps now use i128 for the type. This affects fs.File.Stat, std.time.nanoTimestamp, and fs.File.updateTimes. calendar timestamps are now signed, because the value can be less than the epoch (the user can set their computer time to whatever they wish). implement std.os.clock_gettime for Windows when clock id is CLOCK_CALENDAR.
2020-05-18Undo accidentally checked-in changes to fs/test.zigJakub Konka
2020-05-18Always return false for ANSI escape codes compat in WASIJakub Konka