| ... | @@ -3,6 +3,8 @@ pub const Options = struct { | ... | @@ -3,6 +3,8 @@ pub const Options = struct { |
| 3 | strip_components: u32 = 0, | 3 | strip_components: u32 = 0, |
| 4 | /// How to handle the "mode" property of files from within the tar file. | 4 | /// How to handle the "mode" property of files from within the tar file. |
| 5 | mode_mode: ModeMode = .executable_bit_only, | 5 | mode_mode: ModeMode = .executable_bit_only, |
| | 6 | /// Prevents creation of empty directories. |
| | 7 | exclude_empty_directories: bool = false, |
| 6 | /// Provide this to receive detailed error messages. | 8 | /// Provide this to receive detailed error messages. |
| 7 | /// When this is provided, some errors which would otherwise be returned immediately | 9 | /// When this is provided, some errors which would otherwise be returned immediately |
| 8 | /// will instead be added to this structure. The API user must check the errors | 10 | /// will instead be added to this structure. The API user must check the errors |
| ... | @@ -201,7 +203,7 @@ pub fn pipeToFileSystem(dir: std.fs.Dir, reader: anytype, options: Options) !voi | ... | @@ -201,7 +203,7 @@ pub fn pipeToFileSystem(dir: std.fs.Dir, reader: anytype, options: Options) !voi |
| 201 | switch (header.fileType()) { | 203 | switch (header.fileType()) { |
| 202 | .directory => { | 204 | .directory => { |
| 203 | const file_name = try stripComponents(unstripped_file_name, options.strip_components); | 205 | const file_name = try stripComponents(unstripped_file_name, options.strip_components); |
| 204 | if (file_name.len != 0) { | 206 | if (file_name.len != 0 and !options.exclude_empty_directories) { |
| 205 | try dir.makePath(file_name); | 207 | try dir.makePath(file_name); |
| 206 | } | 208 | } |
| 207 | }, | 209 | }, |