aboutsummaryrefslogtreecommitdiff
path: root/lib/std/fs
AgeCommit message (Collapse)Author
2020-05-18Re-enable refAllDecls gen and check in std.zigJakub Konka
2020-05-18Change to Self from *const Self/*Self where possibleJakub Konka
2020-05-18Make mode_t a 0-byte type in WASIJakub Konka
2020-05-18Add/fix missing WASI functionality to pass libstd testsJakub Konka
This rather large commit adds/fixes missing WASI functionality in `libstd` needed to pass the `libstd` tests. As such, now by default tests targeting `wasm32-wasi` target are enabled in `test/tests.zig` module. However, they can be disabled by passing the `-Dskip-wasi=true` flag when invoking the `zig build test` command. When the flag is set to `false`, i.e., when WASI tests are included, `wasmtime` with `--dir=.` is used as the default testing command. Since the majority of `libstd` tests were relying on `fs.cwd()` call to get current working directory handle wrapped in `Dir` struct, in order to make the tests WASI-friendly, `fs.cwd()` call was replaced with `testing.getTestDir()` function which resolved to either `fs.cwd()` for non-WASI targets, or tries to fetch the preopen list from the WASI runtime and extract a preopen for '.' path. The summary of changes introduced by this commit: * implement `Dir.makeDir` and `Dir.openDir` targeting WASI * implement `Dir.deleteFile` and `Dir.deleteDir` targeting WASI * fix `os.close` and map errors in `unlinkat` * move WASI-specific `mkdirat` and `unlinkat` from `std.fs.wasi` to `std.os` module * implement `lseek_{SET, CUR, END}` targeting WASI * implement `futimens` targeting WASI * implement `ftruncate` targeting WASI * implement `readv`, `writev`, `pread{v}`, `pwrite{v}` targeting WASI * make sure ANSI escape codes are _not_ used in stderr or stdout in WASI, as WASI always sanitizes stderr, and sanitizes stdout if fd is a TTY * fix specifying WASI rights when opening/creating files/dirs * tweak `AtomicFile` to be WASI-compatible * implement `os.renameatWasi` for WASI-compliant `os.renameat` function * implement sleep() targeting WASI * fix `process.getEnvMap` targeting WASI
2020-05-17Merge pull request #5307 from ziglang/self-hosted-incremental-compilationAndrew Kelley
rework self-hosted compiler for incremental builds
2020-05-16Merge pull request #5231 from kubkon/wasi-preopensAndrew Kelley
Add mechanism for extracting preopens from the runtime
2020-05-16Merge remote-tracking branch 'origin/master' into ↵Andrew Kelley
self-hosted-incremental-compilation
2020-05-13self-hosted: fix the rest of the compile errorsAndrew Kelley
2020-05-12self-hosted: rework the memory layout of ir.Module and related typesAndrew Kelley
* add TypedValue.Managed which represents a Type, a Value, and some kind of memory management strategy. * introduce an analysis queue * flesh out how incremental compilation works with respect to exports * ir.text.Module is only capable of one error message during parsing * link.zig no longer has a decl table map and instead has structs that exist directly on ir.Module.Decl and ir.Module.Export * implement primitive .text block allocation * implement linker code for updating Decls and Exports * implement null Type Some supporting std lib changes: * add std.ArrayList.appendSliceAssumeCapacity * add std.fs.File.copyRange and copyRangeAll * fix std.HashMap having modification safety on in ReleaseSmall builds * add std.HashMap.putAssumeCapacityNoClobber
2020-05-05Clear PreopenList on every populate callJakub Konka
2020-05-05Add docsJakub Konka
2020-05-05Move preopen and path wasi helpers to std.fs.wasi moduleJakub Konka
Previously, the path and preopens helpers were prototyped in `std.os.wasi` module, but since they are higher-level abstraction over wasi, they belong in `std.fs.wasi` module.
2020-05-05update comments for nosuspendTadeo Kondrak
2020-05-02Merge remote-tracking branch 'origin/master' into FireFox317-windows-evented-ioAndrew Kelley
2020-05-02fs.File: improve handling async I/O on WindowsAndrew Kelley
Before it was possible for .intended_io_mode = .blocking, .capable_io_mode = .evented, and then the implementation would put a request on the fs thread, which is the wrong behavior. Now it always calls the appropriate WriteFile/ReadFile function, passing the intended io mode directly as a parameter. This makes the behavior tests pass on Windows with --test-evented-io.
2020-05-02correct usages of std.fs.dir.DeleteFileError (#5058)nycex
* correct usages of std.fs.dir.DeleteFileError * test std.fs.createFileAbsolute() and std.fs.deleteFileAbsolute()
2020-05-01cleanup and fixes. behavior tests passing with evented I/OAndrew Kelley
2020-05-01Merge branch 'windows-evented-io' of https://github.com/FireFox317/zig into ↵Andrew Kelley
FireFox317-windows-evented-io
2020-05-01add ZIR compare output test case to test suiteAndrew Kelley
2020-04-22zir-to-elf skeletonAndrew Kelley
2020-04-11ArrayList: remove old (before span) APIxackus
2020-04-11move fs tests to separate file; disable flaky testAndrew Kelley
See #5006
2020-04-07Add lock_nonblocking flag for creating or opening filesLeRoyce Pearson
Also, make windows share delete access. Rationale: this is how it works on Unix systems, mostly because locks are (usually) advisory on Unix.
2020-04-07Make lock option an enumLeRoyce Pearson
For some reason, this breaks file locking on windows. Not sure if this is a problem with wine.
2020-04-02Use `flock` instead of `fcntl` to lock filesLeRoyce Pearson
`flock` locks based on the file handle, instead of the process id. This brings the file locking on unix based systems closer to file locking on Windows.
2020-04-02Merge branch 'master' into feature-file-locksLeRoyce Pearson
2020-03-30std lib API deprecations for the upcoming 0.6.0 releaseAndrew Kelley
See #3811
2020-03-27fix behavior test with --test-evented-io on windowsTimon Kruiper
also make simple file operations work asynchronously on windows
2020-03-23Merge branch 'master' into feature-file-locksLeRoyce Pearson
2020-03-18fix swapped logic for WindowsAndrew Kelley
Remove `std.fs.deleteTree`. Callers instead should use `std.fs.cwd().deleteTree`. Add `std.fs.deleteTreeAbsolute` for when the caller has an absolute path.
2020-03-17Make `fcntlFlock` follow conventions of `os.zig`LeRoyce Pearson
2020-03-14Add note about mandatory locks on linuxLeRoyce Pearson
2020-03-14Add `lock` option to CreateFlagsLeRoyce Pearson
2020-03-14Add `lock` to fs.File.OpenFlagsLeRoyce Pearson
2020-03-13Add NtDll-based ftruncate implementationLemonBoy
2020-03-12Address review commentsLemonBoy
2020-03-12std: Add setEndPos to fs.fileLemonBoy
Allow the user to shrink/grow the file size as needed.
2020-03-11fix footguns in File readAll functionsAndrew Kelley
2020-03-10(breaking) rework stream abstractionsAndrew Kelley
The main goal here is to make the function pointers comptime, so that we don't have to do the crazy stuff with async function frames. Since InStream, OutStream, and SeekableStream are already generic across error sets, it's not really worse to make them generic across the vtable as well. See #764 for the open issue acknowledging that using generics for these abstractions is a design flaw. See #130 for the efforts to make these abstractions non-generic. This commit also changes the OutStream API so that `write` returns number of bytes written, and `writeAll` is the one that loops until the whole buffer is written.
2020-03-08Use os.ino_t for everythingLeRoyce Pearson
Also, define ino_t for windows
2020-03-08Define ino_t for systems not yet defining itLeRoyce Pearson
Also, use ino_t instead of u64 in fs.File.INode
2020-03-08Add documentation about Stat.inodeLeRoyce Pearson
2020-03-08Expose file inode (linux) and file index (windows)LeRoyce Pearson
2020-03-03breaking changes to std.fs, std.osAndrew Kelley
* improve `std.fs.AtomicFile` to use sendfile() - also fix AtomicFile cleanup not destroying tmp files under some error conditions * improve `std.fs.updateFile` to take advantage of the new `makePath` which no longer needs an Allocator. * rename std.fs.makeDir to std.fs.makeDirAbsolute * rename std.fs.Dir.makeDirC to std.fs.Dir.makeDirZ * add std.fs.Dir.makeDirW and provide Windows implementation of std.os.mkdirat. std.os.windows.CreateDirectory is now implemented by calling ntdll, supports an optional root directory handle, and returns an open directory handle. Its error set has a few more errors in it. * rename std.fs.Dir.changeTo to std.fs.Dir.setAsCwd * fix std.fs.File.writevAll and related functions when len 0 iovecs supplied. * introduce `std.fs.File.writeFileAll`, exposing a convenient cross-platform API on top of sendfile(). * `NoDevice` added to std.os.MakeDirError error set. * std.os.fchdir gets a smaller error set. * std.os.windows.CloseHandle is implemented with ntdll call rather than kernel32.
2020-03-03Update callers of fs.makePathdaurnimator
2020-03-03breaking: std.os read/write functions + sendfileAndrew Kelley
* rework os.sendfile and add macosx support, and a fallback implementation for any OS. * fix sendto compile error * std.os write functions support partial writes. closes #3443. * std.os pread / pwrite functions can now return `error.Unseekable`. * std.fs.File read/write functions now have readAll/writeAll variants which loop to complete operations even when partial reads/writes happen. * Audit std.os read/write functions with respect to Linux returning EINVAL for lengths greater than 0x7fff0000. * std.os read/write shim functions do not unnecessarily loop. Since partial reads/writes are part of the API, the caller will be forced to loop anyway, and so that would just be code bloat. * Improve doc comments * Add a non-trivial test for std.os.sendfile * Fix std.os.pread on 32 bit Linux * Add missing SYS_sendfile bit on aarch64
2020-02-28introduce operating system version ranges as part of the targetAndrew Kelley
* re-introduce `std.build.Target` which is distinct from `std.Target`. `std.build.Target` wraps `std.Target` so that it can be annotated as "the native target" or an explicitly specified target. * `std.Target.Os` is moved to `std.Target.Os.Tag`. The former is now a struct which has the tag as well as version range information. * `std.elf` gains some more ELF header constants. * `std.Target.parse` gains the ability to parse operating system version ranges as well as glibc version. * Added `std.Target.isGnuLibC()`. * self-hosted dynamic linker detection and glibc version detection. This also adds the improved logic using `/usr/bin/env` rather than invoking the system C compiler to find the dynamic linker when zig is statically linked. Related: #2084 Note: this `/usr/bin/env` code is work-in-progress. * `-target-glibc` CLI option is removed in favor of the new `-target` syntax. Example: `-target x86_64-linux-gnu.2.27` closes #1907
2020-02-26fix behavior tests with --test-evented-ioAndrew Kelley
2020-02-21remove @bytesToSlice, @sliceToBytes from std libxackus
2020-02-16self-hosted libc detectionAndrew Kelley
* libc_installation.cpp is deleted. src-self-hosted/libc_installation.zig is now used for both stage1 and stage2 compilers. * (breaking) move `std.fs.File.access` to `std.fs.Dir.access`. The API now encourages use with an open directory handle. * Add `std.os.faccessat` and related functions. * Deprecate the "C" suffix naming convention for null-terminated parameters. "C" should be used when it is related to libc. However null-terminated parameters often have to do with the native system ABI rather than libc. "Z" suffix is the new convention. For example, `std.os.openC` is deprecated in favor of `std.os.openZ`. * Add `std.mem.dupeZ` for using an allocator to copy memory and add a null terminator. * Remove dead struct field `std.ChildProcess.llnode`. * Introduce `std.event.Batch`. This API allows expressing concurrency without forcing code to be async. It requires no Allocator and does not introduce any failure conditions. However it is not thread-safe. * There is now an ongoing experiment to transition away from `std.event.Group` in favor of `std.event.Batch`. * `std.os.execvpeC` calls `getenvZ` rather than `getenv`. This is slightly more efficient on most systems, and works around a limitation of `getenv` lack of integration with libc. * (breaking) `std.os.AccessError` gains `FileBusy`, `SymLinkLoop`, and `ReadOnlyFileSystem`. Previously these error codes were all reported as `PermissionDenied`. * Add `std.Target.isDragonFlyBSD`. * stage2: access to the windows_sdk functions is done with a manually maintained .zig binding file instead of `@cImport`. * Update src-self-hosted/libc_installation.zig with all the improvements that stage1 has seen to src/libc_installation.cpp until now. In addition, it now takes advantage of Batch so that evented I/O mode takes advantage of concurrency, but it still works in blocking I/O mode, which is how it is used in stage1.