summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ashby <martin@ashbysoft.com>2023-09-15 22:13:08 +0100
committerMartin Ashby <martin@ashbysoft.com>2023-09-15 22:13:08 +0100
commit3fb260c67ed2812f24cadb154fa10cfc5d1a84f8 (patch)
tree57e1d3561e5b8afaf2e0c6aab3a093b800c235c8
parenta8456d6e83a49ce8cb3ad9a7733cd98dcf26c280 (diff)
downloadzip-zig-3fb260c67ed2812f24cadb154fa10cfc5d1a84f8.tar.gz
zip-zig-3fb260c67ed2812f24cadb154fa10cfc5d1a84f8.tar.bz2
zip-zig-3fb260c67ed2812f24cadb154fa10cfc5d1a84f8.tar.xz
zip-zig-3fb260c67ed2812f24cadb154fa10cfc5d1a84f8.zip
Public functions where appropriate
-rw-r--r--src/main.zig12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/main.zig b/src/main.zig
index f8e2b99..1e006f6 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -58,7 +58,7 @@ allocator: std.mem.Allocator,
end_of_central_directory_record: EndOfCentralDirectoryRecord,
central_directory_headers: []CentralDirectoryHeader,
-fn from(allocator: std.mem.Allocator, file_or_stream: anytype) !@This() {
+pub fn from(allocator: std.mem.Allocator, file_or_stream: anytype) !@This() {
// Find the EndOfCentralDirectoryRecord. It must be in the last 64k of the file
const eocdr_search_width_max: usize = 64_000;
const epos = try file_or_stream.getEndPos();
@@ -97,7 +97,7 @@ fn from(allocator: std.mem.Allocator, file_or_stream: anytype) !@This() {
.central_directory_headers = central_directory_headers,
};
}
-fn deinit(self: *@This()) void {
+pub fn deinit(self: *@This()) void {
self.end_of_central_directory_record.deinit(self.allocator);
for (0..self.central_directory_headers.len) |i| {
self.central_directory_headers[i].deinit(self.allocator);
@@ -105,16 +105,16 @@ fn deinit(self: *@This()) void {
self.allocator.free(self.central_directory_headers);
}
-fn count_files(self: @This()) u16 {
+pub fn count_files(self: @This()) u16 {
return self.end_of_central_directory_record.total_central_dir_entries;
}
-fn file_name(self: @This(), index: u16) []const u8 {
+pub fn file_name(self: @This(), index: u16) []const u8 {
return self.central_directory_headers[index].file_name;
}
-fn file_comment(self: @This(), index: u16) []const u8 {
+pub fn file_comment(self: @This(), index: u16) []const u8 {
return self.central_directory_headers[index].file_comment;
}
-fn extract(self: @This(), index: u16, stream_or_file_in: anytype, stream_or_file_out: anytype) !void {
+pub fn extract(self: @This(), index: u16, stream_or_file_in: anytype, stream_or_file_out: anytype) !void {
const cdh = self.central_directory_headers[index];
try stream_or_file_in.seekTo(cdh.relative_offset_of_local_header);
var lfh = try LocalFileHeader.read(self.allocator, stream_or_file_in);