| ... | @@ -1667,13 +1667,13 @@ pub const UnlinkError = error{ | ... | @@ -1667,13 +1667,13 @@ pub const UnlinkError = error{ |
| 1667 | pub fn unlink(file_path: []const u8) UnlinkError!void { | 1667 | pub fn unlink(file_path: []const u8) UnlinkError!void { |
| 1668 | if (builtin.os.tag == .wasi) { | 1668 | if (builtin.os.tag == .wasi) { |
| 1669 | @compileError("unlink is not supported in WASI; use unlinkat instead"); | 1669 | @compileError("unlink is not supported in WASI; use unlinkat instead"); |
| 1670 | } | 1670 | } else if (builtin.os.tag == .windows) { |
| 1671 | if (builtin.os.tag == .windows) { | | |
| 1672 | const file_path_w = try windows.sliceToPrefixedFileW(file_path); | 1671 | const file_path_w = try windows.sliceToPrefixedFileW(file_path); |
| 1673 | return windows.DeleteFileW(file_path_w.span().ptr); | 1672 | return windows.DeleteFileW(file_path_w.span().ptr); |
| | 1673 | } else { |
| | 1674 | const file_path_c = try toPosixPath(file_path); |
| | 1675 | return unlinkZ(&file_path_c); |
| 1674 | } | 1676 | } |
| 1675 | const file_path_c = try toPosixPath(file_path); | | |
| 1676 | return unlinkZ(&file_path_c); | | |
| 1677 | } | 1677 | } |
| 1678 | | 1678 | |
| 1679 | pub const unlinkC = @compileError("deprecated: renamed to unlinkZ"); | 1679 | pub const unlinkC = @compileError("deprecated: renamed to unlinkZ"); |
| ... | @@ -1874,15 +1874,15 @@ const RenameError = error{ | ... | @@ -1874,15 +1874,15 @@ const RenameError = error{ |
| 1874 | pub fn rename(old_path: []const u8, new_path: []const u8) RenameError!void { | 1874 | pub fn rename(old_path: []const u8, new_path: []const u8) RenameError!void { |
| 1875 | if (builtin.os.tag == .wasi) { | 1875 | if (builtin.os.tag == .wasi) { |
| 1876 | @compileError("rename is not supported in WASI; use renameat instead"); | 1876 | @compileError("rename is not supported in WASI; use renameat instead"); |
| 1877 | } | 1877 | } else if (builtin.os.tag == .windows) { |
| 1878 | if (builtin.os.tag == .windows) { | | |
| 1879 | const old_path_w = try windows.sliceToPrefixedFileW(old_path); | 1878 | const old_path_w = try windows.sliceToPrefixedFileW(old_path); |
| 1880 | const new_path_w = try windows.sliceToPrefixedFileW(new_path); | 1879 | const new_path_w = try windows.sliceToPrefixedFileW(new_path); |
| 1881 | return renameW(old_path_w.span().ptr, new_path_w.span().ptr); | 1880 | return renameW(old_path_w.span().ptr, new_path_w.span().ptr); |
| | 1881 | } else { |
| | 1882 | const old_path_c = try toPosixPath(old_path); |
| | 1883 | const new_path_c = try toPosixPath(new_path); |
| | 1884 | return renameZ(&old_path_c, &new_path_c); |
| 1882 | } | 1885 | } |
| 1883 | const old_path_c = try toPosixPath(old_path); | | |
| 1884 | const new_path_c = try toPosixPath(new_path); | | |
| 1885 | return renameZ(&old_path_c, &new_path_c); | | |
| 1886 | } | 1886 | } |
| 1887 | | 1887 | |
| 1888 | pub const renameC = @compileError("deprecated: renamed to renameZ"); | 1888 | pub const renameC = @compileError("deprecated: renamed to renameZ"); |
| ... | @@ -2153,14 +2153,14 @@ pub fn mkdiratW(dir_fd: fd_t, sub_path_w: [*:0]const u16, mode: u32) MakeDirErro | ... | @@ -2153,14 +2153,14 @@ pub fn mkdiratW(dir_fd: fd_t, sub_path_w: [*:0]const u16, mode: u32) MakeDirErro |
| 2153 | pub fn mkdir(dir_path: []const u8, mode: u32) MakeDirError!void { | 2153 | pub fn mkdir(dir_path: []const u8, mode: u32) MakeDirError!void { |
| 2154 | if (builtin.os.tag == .wasi) { | 2154 | if (builtin.os.tag == .wasi) { |
| 2155 | @compileError("mkdir is not supported in WASI; use mkdirat instead"); | 2155 | @compileError("mkdir is not supported in WASI; use mkdirat instead"); |
| 2156 | } | 2156 | } else if (builtin.os.tag == .windows) { |
| 2157 | if (builtin.os.tag == .windows) { | | |
| 2158 | const sub_dir_handle = try windows.CreateDirectory(null, dir_path, null); | 2157 | const sub_dir_handle = try windows.CreateDirectory(null, dir_path, null); |
| 2159 | windows.CloseHandle(sub_dir_handle); | 2158 | windows.CloseHandle(sub_dir_handle); |
| 2160 | return; | 2159 | return; |
| | 2160 | } else { |
| | 2161 | const dir_path_c = try toPosixPath(dir_path); |
| | 2162 | return mkdirZ(&dir_path_c, mode); |
| 2161 | } | 2163 | } |
| 2162 | const dir_path_c = try toPosixPath(dir_path); | | |
| 2163 | return mkdirZ(&dir_path_c, mode); | | |
| 2164 | } | 2164 | } |
| 2165 | | 2165 | |
| 2166 | /// Same as `mkdir` but the parameter is a null-terminated UTF8-encoded string. | 2166 | /// Same as `mkdir` but the parameter is a null-terminated UTF8-encoded string. |
| ... | @@ -2208,13 +2208,13 @@ pub const DeleteDirError = error{ | ... | @@ -2208,13 +2208,13 @@ pub const DeleteDirError = error{ |
| 2208 | pub fn rmdir(dir_path: []const u8) DeleteDirError!void { | 2208 | pub fn rmdir(dir_path: []const u8) DeleteDirError!void { |
| 2209 | if (builtin.os.tag == .wasi) { | 2209 | if (builtin.os.tag == .wasi) { |
| 2210 | @compileError("rmdir is not supported in WASI; use unlinkat instead"); | 2210 | @compileError("rmdir is not supported in WASI; use unlinkat instead"); |
| 2211 | } | 2211 | } else if (builtin.os.tag == .windows) { |
| 2212 | if (builtin.os.tag == .windows) { | | |
| 2213 | const dir_path_w = try windows.sliceToPrefixedFileW(dir_path); | 2212 | const dir_path_w = try windows.sliceToPrefixedFileW(dir_path); |
| 2214 | return windows.RemoveDirectoryW(dir_path_w.span().ptr); | 2213 | return windows.RemoveDirectoryW(dir_path_w.span().ptr); |
| | 2214 | } else { |
| | 2215 | const dir_path_c = try toPosixPath(dir_path); |
| | 2216 | return rmdirZ(&dir_path_c); |
| 2215 | } | 2217 | } |
| 2216 | const dir_path_c = try toPosixPath(dir_path); | | |
| 2217 | return rmdirZ(&dir_path_c); | | |
| 2218 | } | 2218 | } |
| 2219 | | 2219 | |
| 2220 | pub const rmdirC = @compileError("deprecated: renamed to rmdirZ"); | 2220 | pub const rmdirC = @compileError("deprecated: renamed to rmdirZ"); |
| ... | @@ -2259,13 +2259,13 @@ pub const ChangeCurDirError = error{ | ... | @@ -2259,13 +2259,13 @@ pub const ChangeCurDirError = error{ |
| 2259 | pub fn chdir(dir_path: []const u8) ChangeCurDirError!void { | 2259 | pub fn chdir(dir_path: []const u8) ChangeCurDirError!void { |
| 2260 | if (builtin.os.tag == .wasi) { | 2260 | if (builtin.os.tag == .wasi) { |
| 2261 | @compileError("chdir is not supported in WASI"); | 2261 | @compileError("chdir is not supported in WASI"); |
| 2262 | } | 2262 | } else if (builtin.os.tag == .windows) { |
| 2263 | if (builtin.os.tag == .windows) { | | |
| 2264 | const dir_path_w = try windows.sliceToPrefixedFileW(dir_path); | 2263 | const dir_path_w = try windows.sliceToPrefixedFileW(dir_path); |
| 2265 | @compileError("TODO implement chdir for Windows"); | 2264 | @compileError("TODO implement chdir for Windows"); |
| | 2265 | } else { |
| | 2266 | const dir_path_c = try toPosixPath(dir_path); |
| | 2267 | return chdirZ(&dir_path_c); |
| 2266 | } | 2268 | } |
| 2267 | const dir_path_c = try toPosixPath(dir_path); | | |
| 2268 | return chdirZ(&dir_path_c); | | |
| 2269 | } | 2269 | } |
| 2270 | | 2270 | |
| 2271 | pub const chdirC = @compileError("deprecated: renamed to chdirZ"); | 2271 | pub const chdirC = @compileError("deprecated: renamed to chdirZ"); |
| ... | @@ -2325,13 +2325,13 @@ pub const ReadLinkError = error{ | ... | @@ -2325,13 +2325,13 @@ pub const ReadLinkError = error{ |
| 2325 | pub fn readlink(file_path: []const u8, out_buffer: []u8) ReadLinkError![]u8 { | 2325 | pub fn readlink(file_path: []const u8, out_buffer: []u8) ReadLinkError![]u8 { |
| 2326 | if (builtin.os.tag == .wasi) { | 2326 | if (builtin.os.tag == .wasi) { |
| 2327 | @compileError("readlink is not supported in WASI; use readlinkat instead"); | 2327 | @compileError("readlink is not supported in WASI; use readlinkat instead"); |
| 2328 | } | 2328 | } else if (builtin.os.tag == .windows) { |
| 2329 | if (builtin.os.tag == .windows) { | | |
| 2330 | const file_path_w = try windows.sliceToPrefixedFileW(file_path); | 2329 | const file_path_w = try windows.sliceToPrefixedFileW(file_path); |
| 2331 | return readlinkW(file_path_w.span().ptr, out_buffer); | 2330 | return readlinkW(file_path_w.span().ptr, out_buffer); |
| | 2331 | } else { |
| | 2332 | const file_path_c = try toPosixPath(file_path); |
| | 2333 | return readlinkZ(&file_path_c, out_buffer); |
| 2332 | } | 2334 | } |
| 2333 | const file_path_c = try toPosixPath(file_path); | | |
| 2334 | return readlinkZ(&file_path_c, out_buffer); | | |
| 2335 | } | 2335 | } |
| 2336 | | 2336 | |
| 2337 | pub const readlinkC = @compileError("deprecated: renamed to readlinkZ"); | 2337 | pub const readlinkC = @compileError("deprecated: renamed to readlinkZ"); |
| ... | @@ -3089,6 +3089,9 @@ pub fn fstat(fd: fd_t) FStatError!Stat { | ... | @@ -3089,6 +3089,9 @@ pub fn fstat(fd: fd_t) FStatError!Stat { |
| 3089 | else => |err| return unexpectedErrno(err), | 3089 | else => |err| return unexpectedErrno(err), |
| 3090 | } | 3090 | } |
| 3091 | } | 3091 | } |
| | 3092 | if (builtin.os.tag == .windows) { |
| | 3093 | @compileError("fstat is not yet implemented on Windows"); |
| | 3094 | } |
| 3092 | | 3095 | |
| 3093 | var stat: Stat = undefined; | 3096 | var stat: Stat = undefined; |
| 3094 | switch (errno(system.fstat(fd, &stat))) { | 3097 | switch (errno(system.fstat(fd, &stat))) { |
| ... | @@ -3109,9 +3112,12 @@ pub const FStatAtError = FStatError || error{ NameTooLong, FileNotFound }; | ... | @@ -3109,9 +3112,12 @@ pub const FStatAtError = FStatError || error{ NameTooLong, FileNotFound }; |
| 3109 | pub fn fstatat(dirfd: fd_t, pathname: []const u8, flags: u32) FStatAtError!Stat { | 3112 | pub fn fstatat(dirfd: fd_t, pathname: []const u8, flags: u32) FStatAtError!Stat { |
| 3110 | if (builtin.os.tag == .wasi) { | 3113 | if (builtin.os.tag == .wasi) { |
| 3111 | return fstatatWasi(dirfd, pathname, flags); | 3114 | return fstatatWasi(dirfd, pathname, flags); |
| | 3115 | } else if (builtin.os.tag == .windows) { |
| | 3116 | @compileError("fstatat is not yet implemented on Windows"); |
| | 3117 | } else { |
| | 3118 | const pathname_c = try toPosixPath(pathname); |
| | 3119 | return fstatatZ(dirfd, &pathname_c, flags); |
| 3112 | } | 3120 | } |
| 3113 | const pathname_c = try toPosixPath(pathname); | | |
| 3114 | return fstatatZ(dirfd, &pathname_c, flags); | | |
| 3115 | } | 3121 | } |
| 3116 | | 3122 | |
| 3117 | pub const fstatatC = @compileError("deprecated: renamed to fstatatZ"); | 3123 | pub const fstatatC = @compileError("deprecated: renamed to fstatatZ"); |