aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-05-13 22:12:38 -0400
committerAndrew Kelley <andrew@ziglang.org>2020-05-13 22:12:38 -0400
commit6a2425c38c2a776d2aafd68b25da8c4c1164f614 (patch)
tree418f27f237b06c20907434b90d99350a6f6a9787 /lib/std
parent080022f6c670b0f74c39fe01096ebdbaafeda1b2 (diff)
downloadzig-6a2425c38c2a776d2aafd68b25da8c4c1164f614.tar.gz
zig-6a2425c38c2a776d2aafd68b25da8c4c1164f614.zip
self-hosted: fix the rest of the compile errors
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/fs/file.zig11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/std/fs/file.zig b/lib/std/fs/file.zig
index a33d0d8e3e..9d72733395 100644
--- a/lib/std/fs/file.zig
+++ b/lib/std/fs/file.zig
@@ -527,19 +527,21 @@ pub const File = struct {
}
}
- pub fn copyRange(in: File, in_offset: u64, out: File, out_offset: u64, len: usize) PWriteError!usize {
+ pub const CopyRangeError = PWriteError || PReadError;
+
+ pub fn copyRange(in: File, in_offset: u64, out: File, out_offset: u64, len: usize) CopyRangeError!usize {
// TODO take advantage of copy_file_range OS APIs
var buf: [8 * 4096]u8 = undefined;
const adjusted_count = math.min(buf.len, len);
const amt_read = try in.pread(buf[0..adjusted_count], in_offset);
- if (amt_read == 0) return 0;
+ if (amt_read == 0) return @as(usize, 0);
return out.pwrite(buf[0..amt_read], out_offset);
}
/// Returns the number of bytes copied. If the number read is smaller than `buffer.len`, it
/// means the in file reached the end. Reaching the end of a file is not an error condition.
- pub fn copyRangeAll(in: File, in_offset: u64, out: File, out_offset: u64, len: usize) PWriteError!usize {
- var total_bytes_copied = 0;
+ pub fn copyRangeAll(in: File, in_offset: u64, out: File, out_offset: u64, len: usize) CopyRangeError!usize {
+ var total_bytes_copied: usize = 0;
var in_off = in_offset;
var out_off = out_offset;
while (total_bytes_copied < len) {
@@ -549,6 +551,7 @@ pub const File = struct {
in_off += amt_copied;
out_off += amt_copied;
}
+ return total_bytes_copied;
}
pub const WriteFileOptions = struct {