| ... | ... | @@ -718,7 +718,7 @@ pub const GetCwdError = error{ |
| 718 | 718 | |
| 719 | 719 | /// The result is a slice of out_buffer, indexed from 0. |
| 720 | 720 | pub fn getcwd(out_buffer: []u8) GetCwdError![]u8 { |
| 721 | | if (windows.is_the_target and !builtin.link_libc) { |
| 721 | if (windows.is_the_target) { |
| 722 | 722 | return windows.GetCurrentDirectory(out_buffer); |
| 723 | 723 | } |
| 724 | 724 | |
| ... | ... | @@ -760,7 +760,7 @@ pub const SymLinkError = error{ |
| 760 | 760 | /// If `sym_link_path` exists, it will not be overwritten. |
| 761 | 761 | /// See also `symlinkC` and `symlinkW`. |
| 762 | 762 | pub fn symlink(target_path: []const u8, sym_link_path: []const u8) SymLinkError!void { |
| 763 | | if (windows.is_the_target and !builtin.link_libc) { |
| 763 | if (windows.is_the_target) { |
| 764 | 764 | const target_path_w = try windows.sliceToPrefixedFileW(target_path); |
| 765 | 765 | const sym_link_path_w = try windows.sliceToPrefixedFileW(sym_link_path); |
| 766 | 766 | return windows.CreateSymbolicLinkW(&sym_link_path_w, &target_path_w, 0); |
| ... | ... | @@ -774,7 +774,7 @@ pub fn symlink(target_path: []const u8, sym_link_path: []const u8) SymLinkError! |
| 774 | 774 | /// This is the same as `symlink` except the parameters are null-terminated pointers. |
| 775 | 775 | /// See also `symlink`. |
| 776 | 776 | pub fn symlinkC(target_path: [*]const u8, sym_link_path: [*]const u8) SymLinkError!void { |
| 777 | | if (windows.is_the_target and !builtin.link_libc) { |
| 777 | if (windows.is_the_target) { |
| 778 | 778 | const target_path_w = try windows.cStrToPrefixedFileW(target_path); |
| 779 | 779 | const sym_link_path_w = try windows.cStrToPrefixedFileW(sym_link_path); |
| 780 | 780 | return windows.CreateSymbolicLinkW(&sym_link_path_w, &target_path_w, 0); |
| ... | ... | @@ -850,7 +850,7 @@ pub const UnlinkError = error{ |
| 850 | 850 | /// Delete a name and possibly the file it refers to. |
| 851 | 851 | /// See also `unlinkC`. |
| 852 | 852 | pub fn unlink(file_path: []const u8) UnlinkError!void { |
| 853 | | if (windows.is_the_target and !builtin.link_libc) { |
| 853 | if (windows.is_the_target) { |
| 854 | 854 | const file_path_w = try windows.sliceToPrefixedFileW(file_path); |
| 855 | 855 | return windows.DeleteFileW(&file_path_w); |
| 856 | 856 | } else { |
| ... | ... | @@ -861,7 +861,7 @@ pub fn unlink(file_path: []const u8) UnlinkError!void { |
| 861 | 861 | |
| 862 | 862 | /// Same as `unlink` except the parameter is a null terminated UTF8-encoded string. |
| 863 | 863 | pub fn unlinkC(file_path: [*]const u8) UnlinkError!void { |
| 864 | | if (windows.is_the_target and !builtin.link_libc) { |
| 864 | if (windows.is_the_target) { |
| 865 | 865 | const file_path_w = try windows.cStrToPrefixedFileW(file_path); |
| 866 | 866 | return windows.DeleteFileW(&file_path_w); |
| 867 | 867 | } |
| ... | ... | @@ -906,7 +906,7 @@ const RenameError = error{ |
| 906 | 906 | |
| 907 | 907 | /// Change the name or location of a file. |
| 908 | 908 | pub fn rename(old_path: []const u8, new_path: []const u8) RenameError!void { |
| 909 | | if (windows.is_the_target and !builtin.link_libc) { |
| 909 | if (windows.is_the_target) { |
| 910 | 910 | const old_path_w = try windows.sliceToPrefixedFileW(old_path); |
| 911 | 911 | const new_path_w = try windows.sliceToPrefixedFileW(new_path); |
| 912 | 912 | return renameW(&old_path_w, &new_path_w); |
| ... | ... | @@ -919,7 +919,7 @@ pub fn rename(old_path: []const u8, new_path: []const u8) RenameError!void { |
| 919 | 919 | |
| 920 | 920 | /// Same as `rename` except the parameters are null-terminated byte arrays. |
| 921 | 921 | pub fn renameC(old_path: [*]const u8, new_path: [*]const u8) RenameError!void { |
| 922 | | if (windows.is_the_target and !builtin.link_libc) { |
| 922 | if (windows.is_the_target) { |
| 923 | 923 | const old_path_w = try windows.cStrToPrefixedFileW(old_path); |
| 924 | 924 | const new_path_w = try windows.cStrToPrefixedFileW(new_path); |
| 925 | 925 | return renameW(&old_path_w, &new_path_w); |
| ... | ... | @@ -975,7 +975,7 @@ pub const MakeDirError = error{ |
| 975 | 975 | /// Create a directory. |
| 976 | 976 | /// `mode` is ignored on Windows. |
| 977 | 977 | pub fn mkdir(dir_path: []const u8, mode: u32) MakeDirError!void { |
| 978 | | if (windows.is_the_target and !builtin.link_libc) { |
| 978 | if (windows.is_the_target) { |
| 979 | 979 | const dir_path_w = try windows.sliceToPrefixedFileW(dir_path); |
| 980 | 980 | return windows.CreateDirectoryW(&dir_path_w, null); |
| 981 | 981 | } else { |
| ... | ... | @@ -986,7 +986,7 @@ pub fn mkdir(dir_path: []const u8, mode: u32) MakeDirError!void { |
| 986 | 986 | |
| 987 | 987 | /// Same as `mkdir` but the parameter is a null-terminated UTF8-encoded string. |
| 988 | 988 | pub fn mkdirC(dir_path: [*]const u8, mode: u32) MakeDirError!void { |
| 989 | | if (windows.is_the_target and !builtin.link_libc) { |
| 989 | if (windows.is_the_target) { |
| 990 | 990 | const dir_path_w = try windows.cStrToPrefixedFileW(dir_path); |
| 991 | 991 | return windows.CreateDirectoryW(&dir_path_w, null); |
| 992 | 992 | } |
| ... | ... | @@ -1026,7 +1026,7 @@ pub const DeleteDirError = error{ |
| 1026 | 1026 | |
| 1027 | 1027 | /// Deletes an empty directory. |
| 1028 | 1028 | pub fn rmdir(dir_path: []const u8) DeleteDirError!void { |
| 1029 | | if (windows.is_the_target and !builtin.link_libc) { |
| 1029 | if (windows.is_the_target) { |
| 1030 | 1030 | const dir_path_w = try windows.sliceToPrefixedFileW(dir_path); |
| 1031 | 1031 | return windows.RemoveDirectoryW(&dir_path_w); |
| 1032 | 1032 | } else { |
| ... | ... | @@ -1037,7 +1037,7 @@ pub fn rmdir(dir_path: []const u8) DeleteDirError!void { |
| 1037 | 1037 | |
| 1038 | 1038 | /// Same as `rmdir` except the parameter is null-terminated. |
| 1039 | 1039 | pub fn rmdirC(dir_path: [*]const u8) DeleteDirError!void { |
| 1040 | | if (windows.is_the_target and !builtin.link_libc) { |
| 1040 | if (windows.is_the_target) { |
| 1041 | 1041 | const dir_path_w = try windows.cStrToPrefixedFileW(dir_path); |
| 1042 | 1042 | return windows.RemoveDirectoryW(&dir_path_w); |
| 1043 | 1043 | } |
| ... | ... | @@ -1074,7 +1074,7 @@ pub const ChangeCurDirError = error{ |
| 1074 | 1074 | /// Changes the current working directory of the calling process. |
| 1075 | 1075 | /// `dir_path` is recommended to be a UTF-8 encoded string. |
| 1076 | 1076 | pub fn chdir(dir_path: []const u8) ChangeCurDirError!void { |
| 1077 | | if (windows.is_the_target and !builtin.link_libc) { |
| 1077 | if (windows.is_the_target) { |
| 1078 | 1078 | const dir_path_w = try windows.sliceToPrefixedFileW(dir_path); |
| 1079 | 1079 | @compileError("TODO implement chdir for Windows"); |
| 1080 | 1080 | } else { |
| ... | ... | @@ -1085,7 +1085,7 @@ pub fn chdir(dir_path: []const u8) ChangeCurDirError!void { |
| 1085 | 1085 | |
| 1086 | 1086 | /// Same as `chdir` except the parameter is null-terminated. |
| 1087 | 1087 | pub fn chdirC(dir_path: [*]const u8) ChangeCurDirError!void { |
| 1088 | | if (windows.is_the_target and !builtin.link_libc) { |
| 1088 | if (windows.is_the_target) { |
| 1089 | 1089 | const dir_path_w = try windows.cStrToPrefixedFileW(dir_path); |
| 1090 | 1090 | @compileError("TODO implement chdir for Windows"); |
| 1091 | 1091 | } |
| ... | ... | @@ -1117,7 +1117,7 @@ pub const ReadLinkError = error{ |
| 1117 | 1117 | /// Read value of a symbolic link. |
| 1118 | 1118 | /// The return value is a slice of `out_buffer` from index 0. |
| 1119 | 1119 | pub fn readlink(file_path: []const u8, out_buffer: []u8) ReadLinkError![]u8 { |
| 1120 | | if (windows.is_the_target and !builtin.link_libc) { |
| 1120 | if (windows.is_the_target) { |
| 1121 | 1121 | const file_path_w = try windows.sliceToPrefixedFileW(file_path); |
| 1122 | 1122 | @compileError("TODO implement readlink for Windows"); |
| 1123 | 1123 | } else { |
| ... | ... | @@ -1128,7 +1128,7 @@ pub fn readlink(file_path: []const u8, out_buffer: []u8) ReadLinkError![]u8 { |
| 1128 | 1128 | |
| 1129 | 1129 | /// Same as `readlink` except `file_path` is null-terminated. |
| 1130 | 1130 | pub fn readlinkC(file_path: [*]const u8, out_buffer: []u8) ReadLinkError![]u8 { |
| 1131 | | if (windows.is_the_target and !builtin.link_libc) { |
| 1131 | if (windows.is_the_target) { |
| 1132 | 1132 | const file_path_w = try windows.cStrToPrefixedFileW(file_path); |
| 1133 | 1133 | @compileError("TODO implement readlink for Windows"); |
| 1134 | 1134 | } |
| ... | ... | @@ -1197,9 +1197,6 @@ pub fn setregid(rgid: u32, egid: u32) SetIdError!void { |
| 1197 | 1197 | |
| 1198 | 1198 | /// Test whether a file descriptor refers to a terminal. |
| 1199 | 1199 | pub fn isatty(handle: fd_t) bool { |
| 1200 | | if (builtin.link_libc) { |
| 1201 | | return system.isatty(handle) != 0; |
| 1202 | | } |
| 1203 | 1200 | if (windows.is_the_target) { |
| 1204 | 1201 | if (isCygwinPty(handle)) |
| 1205 | 1202 | return true; |
| ... | ... | @@ -1207,6 +1204,9 @@ pub fn isatty(handle: fd_t) bool { |
| 1207 | 1204 | var out: windows.DWORD = undefined; |
| 1208 | 1205 | return windows.kernel32.GetConsoleMode(handle, &out) != 0; |
| 1209 | 1206 | } |
| 1207 | if (builtin.link_libc) { |
| 1208 | return system.isatty(handle) != 0; |
| 1209 | } |
| 1210 | 1210 | if (wasi.is_the_target) { |
| 1211 | 1211 | @compileError("TODO implement std.os.isatty for WASI"); |
| 1212 | 1212 | } |
| ... | ... | @@ -2003,7 +2003,7 @@ pub const AccessError = error{ |
| 2003 | 2003 | /// check user's permissions for a file |
| 2004 | 2004 | /// TODO currently this assumes `mode` is `F_OK` on Windows. |
| 2005 | 2005 | pub fn access(path: []const u8, mode: u32) AccessError!void { |
| 2006 | | if (windows.is_the_target and !builtin.link_libc) { |
| 2006 | if (windows.is_the_target) { |
| 2007 | 2007 | const path_w = try windows.sliceToPrefixedFileW(path); |
| 2008 | 2008 | _ = try windows.GetFileAttributesW(&path_w); |
| 2009 | 2009 | return; |
| ... | ... | @@ -2014,7 +2014,7 @@ pub fn access(path: []const u8, mode: u32) AccessError!void { |
| 2014 | 2014 | |
| 2015 | 2015 | /// Same as `access` except `path` is null-terminated. |
| 2016 | 2016 | pub fn accessC(path: [*]const u8, mode: u32) AccessError!void { |
| 2017 | | if (windows.is_the_target and !builtin.link_libc) { |
| 2017 | if (windows.is_the_target) { |
| 2018 | 2018 | const path_w = try windows.cStrToPrefixedFileW(path); |
| 2019 | 2019 | _ = try windows.GetFileAttributesW(&path_w); |
| 2020 | 2020 | return; |
| ... | ... | @@ -2132,7 +2132,7 @@ pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void { |
| 2132 | 2132 | else => |err| return unexpectedErrno(err), |
| 2133 | 2133 | } |
| 2134 | 2134 | } |
| 2135 | | if (windows.is_the_target and !builtin.link_libc) { |
| 2135 | if (windows.is_the_target) { |
| 2136 | 2136 | return windows.SetFilePointerEx_BEGIN(fd, offset); |
| 2137 | 2137 | } |
| 2138 | 2138 | const ipos = @bitCast(i64, offset); // the OS treats this as unsigned |
| ... | ... | @@ -2160,7 +2160,7 @@ pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void { |
| 2160 | 2160 | else => |err| return unexpectedErrno(err), |
| 2161 | 2161 | } |
| 2162 | 2162 | } |
| 2163 | | if (windows.is_the_target and !builtin.link_libc) { |
| 2163 | if (windows.is_the_target) { |
| 2164 | 2164 | return windows.SetFilePointerEx_CURRENT(fd, offset); |
| 2165 | 2165 | } |
| 2166 | 2166 | switch (errno(system.lseek(fd, offset, SEEK_CUR))) { |
| ... | ... | @@ -2186,7 +2186,7 @@ pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void { |
| 2186 | 2186 | else => |err| return unexpectedErrno(err), |
| 2187 | 2187 | } |
| 2188 | 2188 | } |
| 2189 | | if (windows.is_the_target and !builtin.link_libc) { |
| 2189 | if (windows.is_the_target) { |
| 2190 | 2190 | return windows.SetFilePointerEx_END(fd, offset); |
| 2191 | 2191 | } |
| 2192 | 2192 | switch (errno(system.lseek(fd, offset, SEEK_END))) { |
| ... | ... | @@ -2214,7 +2214,7 @@ pub fn lseek_CUR_get(fd: fd_t) SeekError!u64 { |
| 2214 | 2214 | else => |err| return unexpectedErrno(err), |
| 2215 | 2215 | } |
| 2216 | 2216 | } |
| 2217 | | if (windows.is_the_target and !builtin.link_libc) { |
| 2217 | if (windows.is_the_target) { |
| 2218 | 2218 | return windows.SetFilePointerEx_CURRENT_get(fd); |
| 2219 | 2219 | } |
| 2220 | 2220 | const rc = system.lseek(fd, 0, SEEK_CUR); |