diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-08-21 21:02:01 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-08-21 21:02:01 -0400 |
| commit | 3d780cf2ef8391b6b48124f599858ee99ddc4cdc (patch) | |
| tree | 5e073a9784a6fa4699e0eca9a3eb0148756e6722 /std/io.zig | |
| parent | b2917e6be09138adcf7cfdab51a1909a30eec320 (diff) | |
| parent | 3dd1026c8bcb438228c336add7cc4014552aa05c (diff) | |
| download | zig-3d780cf2ef8391b6b48124f599858ee99ddc4cdc.tar.gz zig-3d780cf2ef8391b6b48124f599858ee99ddc4cdc.zip | |
Merge branch 'shawnl-path_max'
This does a proof of concept of changing most file system APIs to not
require an allocator and remove the possibility of failure via
OutOfMemory.
This also does most of the work of #534.
Diffstat (limited to 'std/io.zig')
| -rw-r--r-- | std/io.zig | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/std/io.zig b/std/io.zig index 49e03a64b2..c7154065cb 100644 --- a/std/io.zig +++ b/std/io.zig @@ -254,9 +254,8 @@ pub fn OutStream(comptime WriteError: type) type { }; } -/// `path` needs to be copied in memory to add a null terminating byte, hence the allocator. -pub fn writeFile(allocator: *mem.Allocator, path: []const u8, data: []const u8) !void { - var file = try File.openWrite(allocator, path); +pub fn writeFile(path: []const u8, data: []const u8) !void { + var file = try File.openWrite(path); defer file.close(); try file.write(data); } @@ -268,7 +267,7 @@ pub fn readFileAlloc(allocator: *mem.Allocator, path: []const u8) ![]u8 { /// On success, caller owns returned buffer. pub fn readFileAllocAligned(allocator: *mem.Allocator, path: []const u8, comptime A: u29) ![]align(A) u8 { - var file = try File.openRead(allocator, path); + var file = try File.openRead(path); defer file.close(); const size = try file.getEndPos(); |
