| ... | @@ -55,7 +55,7 @@ pub fn writeFile( | ... | @@ -55,7 +55,7 @@ pub fn writeFile( |
| 55 | | 55 | |
| 56 | try w.underlying_writer.writeAll(@ptrCast((&header)[0..1])); | 56 | try w.underlying_writer.writeAll(@ptrCast((&header)[0..1])); |
| 57 | _ = try w.underlying_writer.sendFileAll(file_reader, .unlimited); | 57 | _ = try w.underlying_writer.sendFileAll(file_reader, .unlimited); |
| 58 | try w.writePadding(size); | 58 | try w.writePadding64(size); |
| 59 | } | 59 | } |
| 60 | | 60 | |
| 61 | pub const WriteFileStreamError = Error || std.Io.Reader.StreamError; | 61 | pub const WriteFileStreamError = Error || std.Io.Reader.StreamError; |
| ... | @@ -71,7 +71,7 @@ pub fn writeFileStream( | ... | @@ -71,7 +71,7 @@ pub fn writeFileStream( |
| 71 | ) WriteFileStreamError!void { | 71 | ) WriteFileStreamError!void { |
| 72 | try w.writeHeader(.regular, sub_path, "", size, options); | 72 | try w.writeHeader(.regular, sub_path, "", size, options); |
| 73 | try reader.streamExact64(w.underlying_writer, size); | 73 | try reader.streamExact64(w.underlying_writer, size); |
| 74 | try w.writePadding(size); | 74 | try w.writePadding64(size); |
| 75 | } | 75 | } |
| 76 | | 76 | |
| 77 | /// Writes file using bytes buffer `content` for size and file content. | 77 | /// Writes file using bytes buffer `content` for size and file content. |
| ... | @@ -172,7 +172,14 @@ fn writeExtendedHeader(w: *Writer, typeflag: Header.FileType, buffers: []const [ | ... | @@ -172,7 +172,14 @@ fn writeExtendedHeader(w: *Writer, typeflag: Header.FileType, buffers: []const [ |
| 172 | } | 172 | } |
| 173 | | 173 | |
| 174 | fn writePadding(w: *Writer, bytes: usize) std.Io.Writer.Error!void { | 174 | fn writePadding(w: *Writer, bytes: usize) std.Io.Writer.Error!void { |
| 175 | const pos = bytes % block_size; | 175 | return writePaddingPos(w, bytes % block_size); |
| | 176 | } |
| | 177 | |
| | 178 | fn writePadding64(w: *Writer, bytes: u64) std.Io.Writer.Error!void { |
| | 179 | return writePaddingPos(w, @intCast(bytes % block_size)); |
| | 180 | } |
| | 181 | |
| | 182 | fn writePaddingPos(w: *Writer, pos: usize) std.Io.Writer.Error!void { |
| 176 | if (pos == 0) return; | 183 | if (pos == 0) return; |
| 177 | try w.underlying_writer.splatByteAll(0, block_size - pos); | 184 | try w.underlying_writer.splatByteAll(0, block_size - pos); |
| 178 | } | 185 | } |