mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 04:24:33 +01:00
std.fs: deprecate base64 APIs
100% of std.fs is now deprecated.
This commit is contained in:
parent
c44e12dcd3
commit
7248b4a4e4
5 changed files with 14 additions and 17 deletions
4
lib/compiler/aro/aro/Driver.zig
vendored
4
lib/compiler/aro/aro/Driver.zig
vendored
|
|
@ -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 = .{
|
||||
|
|
|
|||
|
|
@ -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 });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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`.
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue