| ... | @@ -1149,22 +1149,22 @@ pub fn makePath(allocator: *Allocator, full_path: []const u8) !void { | ... | @@ -1149,22 +1149,22 @@ pub fn makePath(allocator: *Allocator, full_path: []const u8) !void { |
| 1149 | | 1149 | |
| 1150 | var end_index: usize = resolved_path.len; | 1150 | var end_index: usize = resolved_path.len; |
| 1151 | while (true) { | 1151 | while (true) { |
| 1152 | makeDir(allocator, resolved_path[0..end_index]) catch |err| { | 1152 | makeDir(allocator, resolved_path[0..end_index]) catch |err| switch (err) { |
| 1153 | if (err == error.PathAlreadyExists) { | 1153 | error.PathAlreadyExists => { |
| 1154 | // TODO stat the file and return an error if it's not a directory | 1154 | // TODO stat the file and return an error if it's not a directory |
| 1155 | // this is important because otherwise a dangling symlink | 1155 | // this is important because otherwise a dangling symlink |
| 1156 | // could cause an infinite loop | 1156 | // could cause an infinite loop |
| 1157 | if (end_index == resolved_path.len) return; | 1157 | if (end_index == resolved_path.len) return; |
| 1158 | } else if (err == error.FileNotFound) { | 1158 | }, |
| | 1159 | error.FileNotFound => { |
| 1159 | // march end_index backward until next path component | 1160 | // march end_index backward until next path component |
| 1160 | while (true) { | 1161 | while (true) { |
| 1161 | end_index -= 1; | 1162 | end_index -= 1; |
| 1162 | if (os.path.isSep(resolved_path[end_index])) break; | 1163 | if (os.path.isSep(resolved_path[end_index])) break; |
| 1163 | } | 1164 | } |
| 1164 | continue; | 1165 | continue; |
| 1165 | } else { | 1166 | }, |
| 1166 | return err; | 1167 | else => return err, |
| 1167 | } | | |
| 1168 | }; | 1168 | }; |
| 1169 | if (end_index == resolved_path.len) return; | 1169 | if (end_index == resolved_path.len) return; |
| 1170 | // march end_index forward until next path component | 1170 | // march end_index forward until next path component |