| ... | ... | @@ -58,6 +58,20 @@ pub fn openFile( |
| 58 | 58 | return p.root_dir.handle.openFile(joined_path, flags); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | pub fn openDir( |
| 62 | p: Path, |
| 63 | sub_path: []const u8, |
| 64 | args: fs.Dir.OpenOptions, |
| 65 | ) fs.Dir.OpenError!fs.Dir { |
| 66 | var buf: [fs.max_path_bytes]u8 = undefined; |
| 67 | const joined_path = if (p.sub_path.len == 0) sub_path else p: { |
| 68 | break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{ |
| 69 | p.sub_path, sub_path, |
| 70 | }) catch return error.NameTooLong; |
| 71 | }; |
| 72 | return p.root_dir.handle.openDir(joined_path, args); |
| 73 | } |
| 74 | |
| 61 | 75 | pub fn makeOpenPath(p: Path, sub_path: []const u8, opts: fs.Dir.OpenOptions) !fs.Dir { |
| 62 | 76 | var buf: [fs.max_path_bytes]u8 = undefined; |
| 63 | 77 | const joined_path = if (p.sub_path.len == 0) sub_path else p: { |
| ... | ... | @@ -137,6 +151,10 @@ pub fn format( |
| 137 | 151 | } |
| 138 | 152 | if (fmt_string.len > 0) |
| 139 | 153 | std.fmt.invalidFmtError(fmt_string, self); |
| 154 | if (std.fs.path.isAbsolute(self.sub_path)) { |
| 155 | try writer.writeAll(self.sub_path); |
| 156 | return; |
| 157 | } |
| 140 | 158 | if (self.root_dir.path) |p| { |
| 141 | 159 | try writer.writeAll(p); |
| 142 | 160 | try writer.writeAll(fs.path.sep_str); |