| ... | ... | @@ -354,6 +354,19 @@ pub const Manifest = struct { |
| 354 | 354 | /// ``` |
| 355 | 355 | /// var file_contents = cache_hash.files.keys()[file_index].contents.?; |
| 356 | 356 | /// ``` |
| 357 | pub fn addFilePath(m: *Manifest, file_path: Path, max_file_size: ?usize) !usize { |
| 358 | const gpa = m.cache.gpa; |
| 359 | try m.files.ensureUnusedCapacity(gpa, 1); |
| 360 | const resolved_path = try fs.path.resolve(gpa, &.{ |
| 361 | file_path.root_dir.path orelse ".", |
| 362 | file_path.subPathOrDot(), |
| 363 | }); |
| 364 | errdefer gpa.free(resolved_path); |
| 365 | const prefixed_path = try m.cache.findPrefixResolved(resolved_path); |
| 366 | return addFileInner(m, prefixed_path, max_file_size); |
| 367 | } |
| 368 | |
| 369 | /// Deprecated; use `addFilePath`. |
| 357 | 370 | pub fn addFile(self: *Manifest, file_path: []const u8, max_file_size: ?usize) !usize { |
| 358 | 371 | assert(self.manifest_file == null); |
| 359 | 372 | |
| ... | ... | @@ -362,6 +375,10 @@ pub const Manifest = struct { |
| 362 | 375 | const prefixed_path = try self.cache.findPrefix(file_path); |
| 363 | 376 | errdefer gpa.free(prefixed_path.sub_path); |
| 364 | 377 | |
| 378 | return addFileInner(self, prefixed_path, max_file_size); |
| 379 | } |
| 380 | |
| 381 | fn addFileInner(self: *Manifest, prefixed_path: PrefixedPath, max_file_size: ?usize) !usize { |
| 365 | 382 | const gop = self.files.getOrPutAssumeCapacityAdapted(prefixed_path, FilesAdapter{}); |
| 366 | 383 | if (gop.found_existing) { |
| 367 | 384 | gop.key_ptr.updateMaxSize(max_file_size); |