34 Commits

Author SHA1 Message Date
Andrew Kelley
66e76a0209
zig build system: correctly handle multiple output artifacts
Previously the zig build system incorrectly assumed that the only build
artifact was a binary. Now, when you enable the cache, only the output
dir is printed to stdout, and the zig build system iterates over the
files in that directory, copying them to the output directory.

To support this change:

 * Add `std.os.renameat`, `std.os.renameatZ`, and `std.os.renameatW`.
 * Fix `std.os.linux.renameat` not compiling due to typos.
 * Deprecate `std.fs.updateFile` and `std.fs.updateFileMode`.
 * Add `std.fs.Dir.updateFile`, which supports using open directory
   handles for both the source and destination paths, as well as an
   options parameter which allows overriding the mode.
 * Update `std.fs.AtomicFile` to support operating based on an open
   directory handle. Instead of `std.fs.AtomicFile.init`, use
   `std.fs.Dir.atomicFile`.
 * `std.fs.AtomicFile` deinit() better handles the situation when the
    rename fails but the temporary file still exists, by still
    attempting to remove the temporary file.
 * `std.fs.Dir.openFileWindows` is moved to `std.os.windows.OpenFileW`.
 * `std.os.RenameError` gains the error codes `NoDevice`,
   `SharingViolation`, and `PipeBusy` which have been observed from
   Windows.

Closes #4733
2020-03-13 21:22:08 -04:00
LemonBoy
de53537f10 Add NtDll-based ftruncate implementation 2020-03-13 08:45:37 +01:00
LemonBoy
b9a1d67637 std: Nicer way to access the PEB
Use the NtCurrentTeb API instead of using some inline asm, this is much
nicer and also more portable.

Closes #4645
2020-03-06 09:06:26 +01:00
Andrew Kelley
ae99fabfe4
Merge pull request #4585 from LemonBoy/fix-4581
target: Implement OS version detection for Windows
2020-03-01 02:53:51 -05:00
daurnimator
d0c22619f5
Complete windows PEB_LDR_DATA definition 2020-03-01 02:10:29 +11:00
daurnimator
513076ee9c
Fill out PEB definition 2020-03-01 00:12:08 +11:00
LemonBoy
f072b0c056 target: Implement OS version detection for Windows
Closes #4581
2020-02-29 12:02:40 +01:00
Andrew Kelley
cfffb9c5e9
improve handling of environment variables on Windows
std.os.getenv and std.os.getenvZ have nice compile errors when not linking
libc and using Windows.

std.os.getenvW is provided as a Windows-only API that does not require
an allocator. It uses the Process Environment Block.
std.process.getEnvVarOwned is improved to be a simple wrapper on top of
std.os.getenvW.

std.process.getEnvMap is improved to use the Process Environment Block
rather than calling GetEnvironmentVariableW.

std.zig.system.NativePaths uses process.getEnvVarOwned instead of
std.os.getenvZ, which works on Windows as well as POSIX.
2020-02-22 17:35:36 -05:00
Andrew Kelley
a795c36d7b
Merge pull request #4352 from LemonBoy/fix-4349
fmt: Respect trailing commas in field declarations
2020-02-02 15:27:53 -05:00
LemonBoy
0bf91cce58 windows: Minor changes to psapi prototypes 2020-02-01 13:43:46 -05:00
LemonBoy
3640c682a2 Run zig fmt 2020-02-01 11:32:53 +01:00
Andrew Kelley
e6a812c827
Merge pull request #4340 from daurnimator/ntstatus-as-enum
Windows error codes as non-exhaustive enums
2020-01-31 18:27:17 -05:00
LemonBoy
9ffc13b6c4 windows: Add psapi API
Export both the "old-style" definitions from psapi and the "new-style"
ones from kernel32.
2020-01-31 23:50:26 +01:00
daurnimator
b9f720365c
Turn win32 errors into a non-exhaustive enum 2020-01-31 22:33:55 +11:00
daurnimator
7cf0b02ab4
NTSTATUS is a non-exhaustive enum 2020-01-31 22:33:17 +11:00
Rocknest
94f29ae117 Remove intCast's 2020-01-30 08:53:38 +02:00
Rocknest
b1884b3a62 Fix aarch64 2020-01-30 01:17:34 +02:00
Rocknest
4a4d6f2be9 Reorganize definitions 2020-01-29 23:15:17 +02:00
Andrew Kelley
7b73c7fe12
Merge branch 'std-utf16-sentinel-terminated' of https://github.com/daurnimator/zig 2020-01-07 16:13:34 -05:00
LemonBoy
563d9ebfe5 Implement the callconv() annotation 2020-01-02 18:53:16 +01:00
daurnimator
2662e50d27
std: sentinel terminated pointers for utf16 apis 2019-12-29 10:35:05 +11:00
daurnimator
8aa3d6019c
std: add windows.USHORT definition 2019-11-27 13:01:30 +11:00
daurnimator
d99f0a2b8f
std: IO_STATUS_BLOCK's status member is an NTSTATUS; add union 2019-11-27 13:01:10 +11:00
daurnimator
b05a5a3e52
std: add CreateEvent for windows 2019-11-27 13:01:03 +11:00
daurnimator
78c0d33eb7
std: add WaitForMultipleObjects for windows 2019-11-27 13:01:02 +11:00
Jonathan S
51c5740879 Use a specific access mask in Dir.openDirListW instead of a generic one. Untested.
The actual desired access mask in this case seems quite confusing and badly documented. The previous combination of `GENERIC_READ` and `SYNCHRONIZE` seems both illegal and redundant according to the [`ntifs.h` documentation](https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/nf-ntifs-ntcreatefile), which specifies that `GENERIC_READ` should not be used for directories and includes `SYNCHRONIZE`. `winnt.h` contains a number of relevant-sounding flags such as `FILE_ADD_FILE`, `FILE_ADD_SUBDIRECTORY`, and `FILE_DELETE_CHILD` that do not show up in documentation at all. These are equal in value to file-specific flags that are documented as flags you should not specify when opening a directory.
2019-11-25 23:46:47 -05:00
daurnimator
be86e41d97
std: add CTL_CODE function for windows 2019-11-14 17:09:16 +11:00
daurnimator
4830415071
std: add FILE_ANY_ constants for windows 2019-11-14 17:00:09 +11:00
daurnimator
0270545edb
std: add windows ioctl transfer types 2019-11-14 17:00:07 +11:00
daurnimator
ef6cec983c
std: add windows FILE_DEVICE_ defines 2019-11-14 17:00:05 +11:00
Andrew Kelley
3cf5c2c62b
fix regressed tests and update docs to use "type coercion" 2019-11-08 15:57:25 -05:00
Andrew Kelley
87f632b08a fs.Dir.openDir: use empty object name for "." on Windows 2019-10-21 19:19:49 -04:00
Andrew Kelley
ef67c49785
[wip] use NtDll APIs on Windows to implement std.fs.Dir 2019-10-21 14:18:01 -04:00
Andrew Kelley
ed36dbbd9c
mv std/ lib/
that's all this commit does. further commits will fix cli flags and
such.

see #2221
2019-09-25 23:35:41 -04:00