diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-10-24 02:25:22 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-24 02:25:22 -0400 |
| commit | 345042ecbc7fb645fd17b69df4e57ffefa5be5a5 (patch) | |
| tree | 457ea0157f0f42dccf905593426154be8682812b /lib/std/fs/file.zig | |
| parent | ef62452363de75240b21299e9f80b4851433faaa (diff) | |
| parent | 60cd11bd4b48e4dfdf11d1f25cb1ee842a49ee1d (diff) | |
| download | zig-345042ecbc7fb645fd17b69df4e57ffefa5be5a5.tar.gz zig-345042ecbc7fb645fd17b69df4e57ffefa5be5a5.zip | |
Merge pull request #3519 from ziglang/move-builtin-types
move types from builtin to std
Diffstat (limited to 'lib/std/fs/file.zig')
| -rw-r--r-- | lib/std/fs/file.zig | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/std/fs/file.zig b/lib/std/fs/file.zig index 44992ff47d..06a26ed481 100644 --- a/lib/std/fs/file.zig +++ b/lib/std/fs/file.zig @@ -27,7 +27,7 @@ pub const File = struct { /// Call close to clean up. pub fn openRead(path: []const u8) OpenError!File { - if (windows.is_the_target) { + if (builtin.os == .windows) { const path_w = try windows.sliceToPrefixedFileW(path); return openReadW(&path_w); } @@ -37,7 +37,7 @@ pub const File = struct { /// `openRead` except with a null terminated path pub fn openReadC(path: [*]const u8) OpenError!File { - if (windows.is_the_target) { + if (builtin.os == .windows) { const path_w = try windows.cStrToPrefixedFileW(path); return openReadW(&path_w); } @@ -69,7 +69,7 @@ pub const File = struct { /// If a file already exists in the destination it will be truncated. /// Call close to clean up. pub fn openWriteMode(path: []const u8, file_mode: Mode) OpenError!File { - if (windows.is_the_target) { + if (builtin.os == .windows) { const path_w = try windows.sliceToPrefixedFileW(path); return openWriteModeW(&path_w, file_mode); } @@ -79,7 +79,7 @@ pub const File = struct { /// Same as `openWriteMode` except `path` is null-terminated. pub fn openWriteModeC(path: [*]const u8, file_mode: Mode) OpenError!File { - if (windows.is_the_target) { + if (builtin.os == .windows) { const path_w = try windows.cStrToPrefixedFileW(path); return openWriteModeW(&path_w, file_mode); } @@ -106,7 +106,7 @@ pub const File = struct { /// If a file already exists in the destination this returns OpenError.PathAlreadyExists /// Call close to clean up. pub fn openWriteNoClobber(path: []const u8, file_mode: Mode) OpenError!File { - if (windows.is_the_target) { + if (builtin.os == .windows) { const path_w = try windows.sliceToPrefixedFileW(path); return openWriteNoClobberW(&path_w, file_mode); } @@ -115,7 +115,7 @@ pub const File = struct { } pub fn openWriteNoClobberC(path: [*]const u8, file_mode: Mode) OpenError!File { - if (windows.is_the_target) { + if (builtin.os == .windows) { const path_w = try windows.cStrToPrefixedFileW(path); return openWriteNoClobberW(&path_w, file_mode); } @@ -174,7 +174,7 @@ pub const File = struct { /// Test whether ANSI escape codes will be treated as such. pub fn supportsAnsiEscapeCodes(self: File) bool { - if (windows.is_the_target) { + if (builtin.os == .windows) { return os.isCygwinPty(self.handle); } if (self.isTty()) { @@ -214,7 +214,7 @@ pub const File = struct { } pub fn getEndPos(self: File) GetPosError!u64 { - if (windows.is_the_target) { + if (builtin.os == .windows) { return windows.GetFileSizeEx(self.handle); } return (try self.stat()).size; @@ -223,7 +223,7 @@ pub const File = struct { pub const ModeError = os.FStatError; pub fn mode(self: File) ModeError!Mode { - if (windows.is_the_target) { + if (builtin.os == .windows) { return {}; } return (try self.stat()).mode; @@ -246,7 +246,7 @@ pub const File = struct { pub const StatError = os.FStatError; pub fn stat(self: File) StatError!Stat { - if (windows.is_the_target) { + if (builtin.os == .windows) { var io_status_block: windows.IO_STATUS_BLOCK = undefined; var info: windows.FILE_ALL_INFORMATION = undefined; const rc = windows.ntdll.NtQueryInformationFile(self.handle, &io_status_block, &info, @sizeOf(windows.FILE_ALL_INFORMATION), .FileAllInformation); @@ -291,7 +291,7 @@ pub const File = struct { /// last modification timestamp in nanoseconds mtime: i64, ) UpdateTimesError!void { - if (windows.is_the_target) { + if (builtin.os == .windows) { const atime_ft = windows.nanoSecondsToFileTime(atime); const mtime_ft = windows.nanoSecondsToFileTime(mtime); return windows.SetFileTime(self.handle, null, &atime_ft, &mtime_ft); |
