diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-05-26 13:37:34 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-05-26 18:32:45 -0400 |
| commit | 44a049e01eef654fee82a1ee4e1aaf37447319ce (patch) | |
| tree | 55fe1e7ae6920f19439d4f7d3424152a133203fb /std/fs.zig | |
| parent | 2f040a23c8b968db56ab4c4725d6651f5ea3418e (diff) | |
| download | zig-44a049e01eef654fee82a1ee4e1aaf37447319ce.tar.gz zig-44a049e01eef654fee82a1ee4e1aaf37447319ce.zip | |
more cleanup. down to just the `@hasDecl` builtin
Diffstat (limited to 'std/fs.zig')
| -rw-r--r-- | std/fs.zig | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/std/fs.zig b/std/fs.zig index b81bc38a75..dcb3143f79 100644 --- a/std/fs.zig +++ b/std/fs.zig @@ -2,7 +2,10 @@ const builtin = @import("builtin"); const std = @import("std.zig"); const os = std.os; const mem = std.mem; +const base64 = std.base64; +const crypto = std.crypto; const Allocator = std.mem.Allocator; +const assert = std.debug.assert; pub const path = @import("fs/path.zig"); pub const File = @import("fs/file.zig").File; @@ -73,7 +76,7 @@ pub fn atomicSymLink(allocator: *Allocator, existing_path: []const u8, new_path: mem.copy(u8, tmp_path[0..], dirname); tmp_path[dirname.len] = path.sep; while (true) { - try getRandomBytes(rand_buf[0..]); + try crypto.randomBytes(rand_buf[0..]); b64_fs_encoder.encode(tmp_path[dirname.len + 1 ..], rand_buf); if (symLink(existing_path, tmp_path)) { @@ -159,7 +162,7 @@ pub const AtomicFile = struct { tmp_path_buf[tmp_path_len] = 0; while (true) { - try getRandomBytes(rand_buf[0..]); + try crypto.randomBytes(rand_buf[0..]); b64_fs_encoder.encode(tmp_path_buf[dirname_component_len..tmp_path_len], rand_buf); const file = File.openWriteNoClobberC(&tmp_path_buf, mode) catch |err| switch (err) { |
