diff options
author | 2022-12-28 00:51:22 -0800 | |
---|---|---|
committer | 2022-12-28 00:51:22 -0800 | |
commit | c0dd2841362b67fdb5ede262b19688004a4eb9a4 (patch) | |
tree | a3cd6b353c25c30d66489de61b394af7d5568fed /src/libarchive/libarchive.zig | |
parent | 504972fa5deb92f2d0510d42f11b085351915a32 (diff) | |
download | bun-c0dd2841362b67fdb5ede262b19688004a4eb9a4.tar.gz bun-c0dd2841362b67fdb5ede262b19688004a4eb9a4.tar.zst bun-c0dd2841362b67fdb5ede262b19688004a4eb9a4.zip |
Upgrade to latest Zig (#1610)
* @min and @max
* builtins and some trivial ones
* Most of them
* more
* more!
* More Progress
* wip
* Update tagged_pointer.zig
* Update http_client_async.zig
* Most of the iterable dir changes
* alright
* Remove usages of deprecated formatters
* :camera:
* fmt
* Update shimmer.zig
* wip
* wip
* wip
* progress
* more
* Latest
* stuck on error
* latest
* workaround stage2
* wip
* Update string_immutable.zig
* wip
* Migrate `Dirent` and `require("fs')` to use JSC<>Zig bindings
* Fix build errors
* Fixup most of the test failures
* Fix `make headers`
* Fix "outside package path" error
* Fixup aligned alloc
* Add missing file
* linux
* More linux fixes
* use latest peechy
* Fix transpiler test failure
* Forgot about these
* Fixup test failure
* Update node-timers.test.ts
* [node:htt] Fix `undefined is not an object` error
Fixes https://github.com/oven-sh/bun/issues/1618
* Update http.exports.js
* Make this test less flaky
* fix hashes
* Fix hex formatting and zls issues
* Download zig version
* Update Dockerfile
* Update Dockerfile
* Update uws
* Update Dockerfile
* Set llvm version
* Update README.md
* Update uws
* Update Dockerfile
* Update io_linux.zig
* Update bun.zig
* Log output
* workaround strange @cInclude error
* Make ffi tests better
* Don't use cImport
* Update c.zig
* Update c-bindings.cpp
* call setOutputDir
* Update Dockerfile
* Use a longer name
* latest
* Update serve.test.ts
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Veikka Tuominen <git@vexu.eu>
Diffstat (limited to 'src/libarchive/libarchive.zig')
-rw-r--r-- | src/libarchive/libarchive.zig | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/libarchive/libarchive.zig b/src/libarchive/libarchive.zig index e10d58660..df260125f 100644 --- a/src/libarchive/libarchive.zig +++ b/src/libarchive/libarchive.zig @@ -401,14 +401,14 @@ pub const Archive = struct { defer stream.deinit(); _ = stream.openRead(); var archive = stream.archive; - const dir: std.fs.Dir = brk: { + const dir: std.fs.IterableDir = brk: { const cwd = std.fs.cwd(); // if the destination doesn't exist, we skip the whole thing since nothing can overwrite it. if (std.fs.path.isAbsolute(root)) { - break :brk std.fs.openDirAbsolute(root, .{ .iterate = true }) catch return; + break :brk std.fs.openIterableDirAbsolute(root, .{}) catch return; } else { - break :brk cwd.openDir(root, .{ .iterate = true }) catch return; + break :brk cwd.openIterableDir(root, .{}) catch return; } }; @@ -436,7 +436,7 @@ pub const Archive = struct { const size = @intCast(usize, std.math.max(lib.archive_entry_size(entry), 0)); if (size > 0) { - var opened = dir.openFileZ(pathname, .{ .mode = .write_only }) catch continue :loop; + var opened = dir.dir.openFileZ(pathname, .{ .mode = .write_only }) catch continue :loop; var stat = try opened.stat(); if (stat.size > 0) { @@ -470,7 +470,7 @@ pub const Archive = struct { pub fn extractToDir( file_buffer: []const u8, - dir: std.fs.Dir, + dir_: std.fs.IterableDir, ctx: ?*Archive.Context, comptime FilePathAppender: type, appender: FilePathAppender, @@ -486,6 +486,8 @@ pub const Archive = struct { _ = stream.openRead(); var archive = stream.archive; var count: u32 = 0; + const dir = dir_.dir; + const dir_fd = dir.fd; loop: while (true) { const r = @intToEnum(Status, lib.archive_read_next_header(archive, &entry)); @@ -530,20 +532,20 @@ pub const Archive = struct { if ((mode & 0o4) != 0) mode |= 0o1; - std.os.mkdiratZ(dir.fd, pathname, @intCast(u32, mode)) catch |err| { + std.os.mkdiratZ(dir_fd, pathname, @intCast(u32, mode)) catch |err| { if (err == error.PathAlreadyExists or err == error.NotDir) break; try dir.makePath(std.fs.path.dirname(slice) orelse return err); - try std.os.mkdiratZ(dir.fd, pathname, 0o777); + try std.os.mkdiratZ(dir_fd, pathname, 0o777); }; }, Kind.SymLink => { const link_target = lib.archive_entry_symlink(entry).?; - std.os.symlinkatZ(link_target, dir.fd, pathname) catch |err| brk: { + std.os.symlinkatZ(link_target, dir_fd, pathname) catch |err| brk: { switch (err) { error.AccessDenied, error.FileNotFound => { dir.makePath(std.fs.path.dirname(slice) orelse return err) catch {}; - break :brk try std.os.symlinkatZ(link_target, dir.fd, pathname); + break :brk try std.os.symlinkatZ(link_target, dir_fd, pathname); }, else => { return err; @@ -569,7 +571,7 @@ pub const Archive = struct { }; defer if (comptime close_handles) file.close(); - const entry_size = @maximum(lib.archive_entry_size(entry), 0); + const entry_size = @max(lib.archive_entry_size(entry), 0); const size = @intCast(usize, entry_size); if (size > 0) { if (ctx) |ctx_| { @@ -647,16 +649,16 @@ pub const Archive = struct { comptime close_handles: bool, comptime log: bool, ) !u32 { - var dir: std.fs.Dir = brk: { + var dir: std.fs.IterableDir = brk: { const cwd = std.fs.cwd(); cwd.makePath( root, ) catch {}; if (std.fs.path.isAbsolute(root)) { - break :brk try std.fs.openDirAbsolute(root, .{ .iterate = true }); + break :brk try std.fs.openIterableDirAbsolute(root, .{}); } else { - break :brk try cwd.openDir(root, .{ .iterate = true }); + break :brk try cwd.openIterableDir(root, .{}); } }; |