aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-10-07 00:42:58 -0700
committerAndrew Kelley <andrew@ziglang.org>2020-10-07 00:42:58 -0700
commitf2d374e8465042fa5cb6bf2be7b9b086948f3a94 (patch)
tree28b7a8997249dafa8b1171e789fbb0dfce2a9d56 /lib/std
parentfb63a2cfaecb981010e0b9d656fd372dbb331888 (diff)
parentb2b0bf0506e708e6b8c143eb438a84592310b5a9 (diff)
downloadzig-f2d374e8465042fa5cb6bf2be7b9b086948f3a94.tar.gz
zig-f2d374e8465042fa5cb6bf2be7b9b086948f3a94.zip
Merge branch 'FireFox317-fix-32-bit-target'
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/fs/file.zig16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/std/fs/file.zig b/lib/std/fs/file.zig
index 8d4f5df2e8..bfa6dec3ed 100644
--- a/lib/std/fs/file.zig
+++ b/lib/std/fs/file.zig
@@ -615,7 +615,7 @@ pub const File = struct {
}
}
- pub fn pwritev(self: File, iovecs: []os.iovec_const, offset: usize) PWriteError!usize {
+ pub fn pwritev(self: File, iovecs: []os.iovec_const, offset: u64) PWriteError!usize {
if (is_windows) {
// TODO improve this to use WriteFileScatter
if (iovecs.len == 0) return @as(usize, 0);
@@ -632,11 +632,11 @@ pub const File = struct {
/// The `iovecs` parameter is mutable because this function needs to mutate the fields in
/// order to handle partial writes from the underlying OS layer.
- pub fn pwritevAll(self: File, iovecs: []os.iovec_const, offset: usize) PWriteError!void {
+ pub fn pwritevAll(self: File, iovecs: []os.iovec_const, offset: u64) PWriteError!void {
if (iovecs.len == 0) return;
var i: usize = 0;
- var off: usize = 0;
+ var off: u64 = 0;
while (true) {
var amt = try self.pwritev(iovecs[i..], offset + off);
off += amt;
@@ -652,14 +652,16 @@ pub const File = struct {
pub const CopyRangeError = os.CopyFileRangeError;
- pub fn copyRange(in: File, in_offset: u64, out: File, out_offset: u64, len: usize) CopyRangeError!usize {
- return os.copy_file_range(in.handle, in_offset, out.handle, out_offset, len, 0);
+ pub fn copyRange(in: File, in_offset: u64, out: File, out_offset: u64, len: u64) CopyRangeError!u64 {
+ const adjusted_len = math.cast(usize, len) catch math.maxInt(usize);
+ const result = try os.copy_file_range(in.handle, in_offset, out.handle, out_offset, adjusted_len, 0);
+ return result;
}
/// 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) CopyRangeError!usize {
- var total_bytes_copied: usize = 0;
+ pub fn copyRangeAll(in: File, in_offset: u64, out: File, out_offset: u64, len: u64) CopyRangeError!u64 {
+ var total_bytes_copied: u64 = 0;
var in_off = in_offset;
var out_off = out_offset;
while (total_bytes_copied < len) {