mirror of
https://github.com/ziglang/zig.git
synced 2026-10-14 10:27:43 -04:00
std.tar: fix broken public interface
This commit is contained in:
1 parent
c4868b2bbc
commit
0cca7e732e
2 files changed
+27
-31
No files matched your search
+26
-30
@@ -21,30 +21,10 @@ const testing = std.testing;
|
||||
|
||||
pub const output = @import("tar/output.zig");
|
||||
|
||||
/// pipeToFileSystem options
|
||||
pub const PipeOptions = struct {
|
||||
/// Number of directory levels to skip when extracting files.
|
||||
strip_components: u32 = 0,
|
||||
/// How to handle the "mode" property of files from within the tar file.
|
||||
mode_mode: ModeMode = .executable_bit_only,
|
||||
/// Prevents creation of empty directories.
|
||||
exclude_empty_directories: bool = false,
|
||||
/// Provide this to receive detailed error messages.
|
||||
/// When this is provided, some errors which would otherwise be returned immediately
|
||||
/// will instead be added to this structure. The API user must check the errors
|
||||
/// in diagnostics to know whether the operation succeeded or failed.
|
||||
diagnostics: ?*Diagnostics = null,
|
||||
|
||||
pub const ModeMode = enum {
|
||||
/// The mode from the tar file is completely ignored. Files are created
|
||||
/// with the default mode when creating files.
|
||||
ignore,
|
||||
/// The mode from the tar file is inspected for the owner executable bit
|
||||
/// only. This bit is copied to the group and other executable bits.
|
||||
/// Other bits of the mode are left as the default when creating files.
|
||||
executable_bit_only,
|
||||
};
|
||||
|
||||
/// When this is provided, some errors which would otherwise be returned
|
||||
/// immediately will instead be added to this structure. The API user must check
|
||||
/// the errors in diagnostics to know whether the operation succeeded or failed.
|
||||
pub const Diagnostics = struct {
|
||||
allocator: std.mem.Allocator,
|
||||
errors: std.ArrayListUnmanaged(Error) = .{},
|
||||
@@ -84,6 +64,27 @@ pub const PipeOptions = struct {
|
||||
d.* = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
/// pipeToFileSystem options
|
||||
pub const PipeOptions = struct {
|
||||
/// Number of directory levels to skip when extracting files.
|
||||
strip_components: u32 = 0,
|
||||
/// How to handle the "mode" property of files from within the tar file.
|
||||
mode_mode: ModeMode = .executable_bit_only,
|
||||
/// Prevents creation of empty directories.
|
||||
exclude_empty_directories: bool = false,
|
||||
/// Collects error messages during unpacking
|
||||
diagnostics: ?*Diagnostics = null,
|
||||
|
||||
pub const ModeMode = enum {
|
||||
/// The mode from the tar file is completely ignored. Files are created
|
||||
/// with the default mode when creating files.
|
||||
ignore,
|
||||
/// The mode from the tar file is inspected for the owner executable bit
|
||||
/// only. This bit is copied to the group and other executable bits.
|
||||
/// Other bits of the mode are left as the default when creating files.
|
||||
executable_bit_only,
|
||||
};
|
||||
};
|
||||
|
||||
const Header = struct {
|
||||
@@ -246,13 +247,8 @@ pub const IteratorOptions = struct {
|
||||
file_name_buffer: []u8,
|
||||
/// Use a buffer with length `std.fs.MAX_PATH_BYTES` to match file system capabilities.
|
||||
link_name_buffer: []u8,
|
||||
/// Provide this to receive detailed error messages.
|
||||
/// When this is provided, some errors which would otherwise be returned immediately
|
||||
/// will instead be added to this structure. The API user must check the errors
|
||||
/// in diagnostics to know whether the operation succeeded or failed.
|
||||
/// Collects error messages during unpacking
|
||||
diagnostics: ?*Diagnostics = null,
|
||||
|
||||
pub const Diagnostics = PipeOptions.Diagnostics;
|
||||
};
|
||||
|
||||
/// Iterates over files in tar archive.
|
||||
@@ -277,7 +273,7 @@ pub const FileKind = enum {
|
||||
pub fn Iterator(comptime ReaderType: type) type {
|
||||
return struct {
|
||||
reader: ReaderType,
|
||||
diagnostics: ?*PipeOptions.Diagnostics = null,
|
||||
diagnostics: ?*Diagnostics = null,
|
||||
|
||||
// buffers for heeader and file attributes
|
||||
header_buffer: [Header.SIZE]u8 = undefined,
|
||||
|
||||
@@ -1147,7 +1147,7 @@ fn unpackTarball(f: *Fetch, out_dir: fs.Dir, reader: anytype) RunError!void {
|
||||
const eb = &f.error_bundle;
|
||||
const gpa = f.arena.child_allocator;
|
||||
|
||||
var diagnostics: std.tar.Options.Diagnostics = .{ .allocator = gpa };
|
||||
var diagnostics: std.tar.Diagnostics = .{ .allocator = gpa };
|
||||
defer diagnostics.deinit();
|
||||
|
||||
std.tar.pipeToFileSystem(out_dir, reader, .{
|
||||
|
||||
Reference in new issue
Block a user