authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-07 12:44:17-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-07 17:33:06-08:00
log7248b4a4e437223a0c826dfbcb76b9835fce16d0
tree4ead7ce724ce6928c1041c43307a869f393a5a5f
parentc44e12dcd309ae4f18903d66e262c07f0a318296

std.fs: deprecate base64 APIs

100% of std.fs is now deprecated.

5 files changed, 14 insertions(+), 17 deletions(-)

lib/compiler/aro/aro/Driver.zig+2-2
......@@ -1219,12 +1219,12 @@ pub fn getDepFileName(d: *Driver, source: Source, buf: *[std.fs.max_name_bytes]u
12191219fn getRandomFilename(d: *Driver, buf: *[std.fs.max_name_bytes]u8, extension: []const u8) ![]const u8 {
12201220 const io = d.comp.io;
12211221 const random_bytes_count = 12;
1222 const sub_path_len = comptime std.fs.base64_encoder.calcSize(random_bytes_count);
1222 const sub_path_len = comptime std.base64.url_safe.Encoder.calcSize(random_bytes_count);
12231223
12241224 var random_bytes: [random_bytes_count]u8 = undefined;
12251225 io.random(&random_bytes);
12261226 var random_name: [sub_path_len]u8 = undefined;
1227 _ = std.fs.base64_encoder.encode(&random_name, &random_bytes);
1227 _ = std.base64.url_safe.Encoder.encode(&random_name, &random_bytes);
12281228
12291229 const fmt_template = "/tmp/{s}{s}";
12301230 const fmt_args = .{
lib/std/Io/net/test.zig+2-2
......@@ -310,11 +310,11 @@ test "listen on a unix socket, send bytes, receive bytes" {
310310
311311fn generateFileName(io: Io, base_name: []const u8) ![]const u8 {
312312 const random_bytes_count = 12;
313 const sub_path_len = comptime std.fs.base64_encoder.calcSize(random_bytes_count);
313 const sub_path_len = comptime std.base64.url_safe.Encoder.calcSize(random_bytes_count);
314314 var random_bytes: [12]u8 = undefined;
315315 io.random(&random_bytes);
316316 var sub_path: [sub_path_len]u8 = undefined;
317 _ = std.fs.base64_encoder.encode(&sub_path, &random_bytes);
317 _ = std.base64.url_safe.Encoder.encode(&sub_path, &random_bytes);
318318 return std.fmt.allocPrint(testing.allocator, "{s}-{s}", .{ sub_path[0..], base_name });
319319}
320320
lib/std/fs.zig+6-9
......@@ -4,15 +4,12 @@ const std = @import("std.zig");
44
55/// Deprecated, use `std.Io.Dir.path`.
66pub const path = @import("fs/path.zig");
7
8pub const base64_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".*;
9
10/// Base64 encoder, replacing the standard `+/` with `-_` so that it can be used in a file name on any filesystem.
11pub const base64_encoder = std.base64.Base64Encoder.init(base64_alphabet, null);
12
13/// Base64 decoder, replacing the standard `+/` with `-_` so that it can be used in a file name on any filesystem.
14pub const base64_decoder = std.base64.Base64Decoder.init(base64_alphabet, null);
15
7/// Deprecated, use `std.base64.url_safe_alphabet_chars`.
8pub const base64_alphabet = std.base64.url_safe_alphabet_chars;
9/// Deprecated, use `std.base64.url_safe.Encoder`.
10pub const base64_encoder = std.base64.url_safe.Encoder;
11/// Deprecated, use `std.base64.url_safe.Decoder`.
12pub const base64_decoder = std.base64.url_safe.Decoder;
1613/// Deprecated, use `std.Io.Dir.max_path_bytes`.
1714pub const max_path_bytes = std.Io.Dir.max_path_bytes;
1815/// Deprecated, use `std.Io.Dir.max_name_bytes`.
lib/std/fs/test.zig+2-2
......@@ -1777,8 +1777,8 @@ test "open file with exclusive nonblocking lock twice (absolute paths)" {
17771777 var random_bytes: [12]u8 = undefined;
17781778 io.random(&random_bytes);
17791779
1780 var random_b64: [std.fs.base64_encoder.calcSize(random_bytes.len)]u8 = undefined;
1781 _ = std.fs.base64_encoder.encode(&random_b64, &random_bytes);
1780 var random_b64: [std.base64.url_safe.Encoder.calcSize(random_bytes.len)]u8 = undefined;
1781 _ = std.base64.url_safe.Encoder.encode(&random_b64, &random_bytes);
17821782
17831783 const sub_path = random_b64 ++ "-zig-test-absolute-paths.txt";
17841784
lib/std/testing.zig+2-2
......@@ -618,7 +618,7 @@ pub const TmpDir = struct {
618618 sub_path: [sub_path_len]u8,
619619
620620 const random_bytes_count = 12;
621 const sub_path_len = std.fs.base64_encoder.calcSize(random_bytes_count);
621 const sub_path_len = std.base64.url_safe.Encoder.calcSize(random_bytes_count);
622622
623623 pub fn cleanup(self: *TmpDir) void {
624624 self.dir.close(io);
......@@ -633,7 +633,7 @@ pub fn tmpDir(opts: Io.Dir.OpenOptions) TmpDir {
633633 var random_bytes: [TmpDir.random_bytes_count]u8 = undefined;
634634 io.random(&random_bytes);
635635 var sub_path: [TmpDir.sub_path_len]u8 = undefined;
636 _ = std.fs.base64_encoder.encode(&sub_path, &random_bytes);
636 _ = std.base64.url_safe.Encoder.encode(&sub_path, &random_bytes);
637637
638638 const cwd = Io.Dir.cwd();
639639 var cache_dir = cwd.createDirPathOpen(io, ".zig-cache", .{}) catch