diff --git a/lib/compiler/aro/aro/Driver.zig b/lib/compiler/aro/aro/Driver.zig index 154b4d56a5..5c356dc5b1 100644 --- a/lib/compiler/aro/aro/Driver.zig +++ b/lib/compiler/aro/aro/Driver.zig @@ -1219,12 +1219,12 @@ pub fn getDepFileName(d: *Driver, source: Source, buf: *[std.fs.max_name_bytes]u fn getRandomFilename(d: *Driver, buf: *[std.fs.max_name_bytes]u8, extension: []const u8) ![]const u8 { const io = d.comp.io; const random_bytes_count = 12; - const sub_path_len = comptime std.fs.base64_encoder.calcSize(random_bytes_count); + const sub_path_len = comptime std.base64.url_safe.Encoder.calcSize(random_bytes_count); var random_bytes: [random_bytes_count]u8 = undefined; io.random(&random_bytes); var random_name: [sub_path_len]u8 = undefined; - _ = std.fs.base64_encoder.encode(&random_name, &random_bytes); + _ = std.base64.url_safe.Encoder.encode(&random_name, &random_bytes); const fmt_template = "/tmp/{s}{s}"; const fmt_args = .{ diff --git a/lib/std/Io/net/test.zig b/lib/std/Io/net/test.zig index 75f72d3aff..7904bc4641 100644 --- a/lib/std/Io/net/test.zig +++ b/lib/std/Io/net/test.zig @@ -310,11 +310,11 @@ test "listen on a unix socket, send bytes, receive bytes" { fn generateFileName(io: Io, base_name: []const u8) ![]const u8 { const random_bytes_count = 12; - const sub_path_len = comptime std.fs.base64_encoder.calcSize(random_bytes_count); + const sub_path_len = comptime std.base64.url_safe.Encoder.calcSize(random_bytes_count); var random_bytes: [12]u8 = undefined; io.random(&random_bytes); var sub_path: [sub_path_len]u8 = undefined; - _ = std.fs.base64_encoder.encode(&sub_path, &random_bytes); + _ = std.base64.url_safe.Encoder.encode(&sub_path, &random_bytes); return std.fmt.allocPrint(testing.allocator, "{s}-{s}", .{ sub_path[0..], base_name }); } diff --git a/lib/std/fs.zig b/lib/std/fs.zig index 93c2a9a0ae..a127da1696 100644 --- a/lib/std/fs.zig +++ b/lib/std/fs.zig @@ -4,15 +4,12 @@ const std = @import("std.zig"); /// Deprecated, use `std.Io.Dir.path`. pub const path = @import("fs/path.zig"); - -pub const base64_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".*; - -/// Base64 encoder, replacing the standard `+/` with `-_` so that it can be used in a file name on any filesystem. -pub const base64_encoder = std.base64.Base64Encoder.init(base64_alphabet, null); - -/// Base64 decoder, replacing the standard `+/` with `-_` so that it can be used in a file name on any filesystem. -pub const base64_decoder = std.base64.Base64Decoder.init(base64_alphabet, null); - +/// Deprecated, use `std.base64.url_safe_alphabet_chars`. +pub const base64_alphabet = std.base64.url_safe_alphabet_chars; +/// Deprecated, use `std.base64.url_safe.Encoder`. +pub const base64_encoder = std.base64.url_safe.Encoder; +/// Deprecated, use `std.base64.url_safe.Decoder`. +pub const base64_decoder = std.base64.url_safe.Decoder; /// Deprecated, use `std.Io.Dir.max_path_bytes`. pub const max_path_bytes = std.Io.Dir.max_path_bytes; /// Deprecated, use `std.Io.Dir.max_name_bytes`. diff --git a/lib/std/fs/test.zig b/lib/std/fs/test.zig index a584fa3477..a9fdab1ae0 100644 --- a/lib/std/fs/test.zig +++ b/lib/std/fs/test.zig @@ -1777,8 +1777,8 @@ test "open file with exclusive nonblocking lock twice (absolute paths)" { var random_bytes: [12]u8 = undefined; io.random(&random_bytes); - var random_b64: [std.fs.base64_encoder.calcSize(random_bytes.len)]u8 = undefined; - _ = std.fs.base64_encoder.encode(&random_b64, &random_bytes); + var random_b64: [std.base64.url_safe.Encoder.calcSize(random_bytes.len)]u8 = undefined; + _ = std.base64.url_safe.Encoder.encode(&random_b64, &random_bytes); const sub_path = random_b64 ++ "-zig-test-absolute-paths.txt"; diff --git a/lib/std/testing.zig b/lib/std/testing.zig index 1138869663..03e1d06c18 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -618,7 +618,7 @@ pub const TmpDir = struct { sub_path: [sub_path_len]u8, const random_bytes_count = 12; - const sub_path_len = std.fs.base64_encoder.calcSize(random_bytes_count); + const sub_path_len = std.base64.url_safe.Encoder.calcSize(random_bytes_count); pub fn cleanup(self: *TmpDir) void { self.dir.close(io); @@ -633,7 +633,7 @@ pub fn tmpDir(opts: Io.Dir.OpenOptions) TmpDir { var random_bytes: [TmpDir.random_bytes_count]u8 = undefined; io.random(&random_bytes); var sub_path: [TmpDir.sub_path_len]u8 = undefined; - _ = std.fs.base64_encoder.encode(&sub_path, &random_bytes); + _ = std.base64.url_safe.Encoder.encode(&sub_path, &random_bytes); const cwd = Io.Dir.cwd(); var cache_dir = cwd.createDirPathOpen(io, ".zig-cache", .{}) catch