| ... | ... | @@ -50,15 +50,15 @@ const PathType = enum { |
| 50 | 50 | .unc => return struct { |
| 51 | 51 | fn transform(allocator: mem.Allocator, dir: Dir, relative_path: []const u8) TransformError![]const u8 { |
| 52 | 52 | // Any drive absolute path (C:\foo) can be converted into a UNC path by |
| 53 | | // using 'localhost' as the server name and '<drive letter>$' as the share name. |
| 53 | // using '127.0.0.1' as the server name and '<drive letter>$' as the share name. |
| 54 | 54 | var fd_path_buf: [fs.MAX_PATH_BYTES]u8 = undefined; |
| 55 | 55 | const dir_path = try os.getFdPath(dir.fd, &fd_path_buf); |
| 56 | 56 | const windows_path_type = std.os.windows.getUnprefixedPathType(u8, dir_path); |
| 57 | 57 | switch (windows_path_type) { |
| 58 | 58 | .unc_absolute => return fs.path.join(allocator, &.{ dir_path, relative_path }), |
| 59 | 59 | .drive_absolute => { |
| 60 | | // `C:\<...>` -> `\\localhost\C$\<...>` |
| 61 | | const prepended = "\\\\localhost\\"; |
| 60 | // `C:\<...>` -> `\\127.0.0.1\C$\<...>` |
| 61 | const prepended = "\\\\127.0.0.1\\"; |
| 62 | 62 | var path = try fs.path.join(allocator, &.{ prepended, dir_path, relative_path }); |
| 63 | 63 | path[prepended.len + 1] = '$'; |
| 64 | 64 | return path; |
| ... | ... | @@ -117,7 +117,7 @@ fn testWithAllSupportedPathTypes(test_func: anytype) !void { |
| 117 | 117 | defer ctx.deinit(); |
| 118 | 118 | |
| 119 | 119 | test_func(&ctx) catch |err| { |
| 120 | | std.debug.print("path type: {s}\n", .{enum_field.name}); |
| 120 | std.debug.print("{s}, path type: {s}\n", .{ @errorName(err), enum_field.name }); |
| 121 | 121 | return err; |
| 122 | 122 | }; |
| 123 | 123 | } |