| ... | @@ -1527,7 +1527,7 @@ pub const Writer = struct { | ... | @@ -1527,7 +1527,7 @@ pub const Writer = struct { |
| 1527 | Unexpected, | 1527 | Unexpected, |
| 1528 | }; | 1528 | }; |
| 1529 | | 1529 | |
| 1530 | pub const SeekError = File.SeekError || std.Io.Writer.Error; | 1530 | pub const SeekError = File.SeekError; |
| 1531 | | 1531 | |
| 1532 | /// Number of slices to store on the stack, when trying to send as many byte | 1532 | /// Number of slices to store on the stack, when trying to send as many byte |
| 1533 | /// vectors through the underlying write calls as possible. | 1533 | /// vectors through the underlying write calls as possible. |
| ... | @@ -1572,7 +1572,7 @@ pub const Writer = struct { | ... | @@ -1572,7 +1572,7 @@ pub const Writer = struct { |
| 1572 | .mode = w.mode, | 1572 | .mode = w.mode, |
| 1573 | .pos = w.pos, | 1573 | .pos = w.pos, |
| 1574 | .interface = Reader.initInterface(w.interface.buffer), | 1574 | .interface = Reader.initInterface(w.interface.buffer), |
| 1575 | .seek_err = null, | 1575 | .seek_err = w.seek_err, |
| 1576 | }; | 1576 | }; |
| 1577 | } | 1577 | } |
| 1578 | | 1578 | |
| ... | @@ -2002,8 +2002,14 @@ pub const Writer = struct { | ... | @@ -2002,8 +2002,14 @@ pub const Writer = struct { |
| 2002 | return n; | 2002 | return n; |
| 2003 | } | 2003 | } |
| 2004 | | 2004 | |
| 2005 | pub fn seekTo(w: *Writer, offset: u64) Writer.SeekError!void { | 2005 | pub fn seekTo(w: *Writer, offset: u64) (Writer.SeekError || std.Io.Writer.Error)!void { |
| 2006 | try w.interface.flush(); | 2006 | try w.interface.flush(); |
| | 2007 | try seekToUnbuffered(w, offset); |
| | 2008 | } |
| | 2009 | |
| | 2010 | /// Asserts that no data is currently buffered. |
| | 2011 | pub fn seekToUnbuffered(w: *Writer, offset: u64) Writer.SeekError!void { |
| | 2012 | assert(w.interface.buffered().len == 0); |
| 2007 | switch (w.mode) { | 2013 | switch (w.mode) { |
| 2008 | .positional, .positional_reading => { | 2014 | .positional, .positional_reading => { |
| 2009 | w.pos = offset; | 2015 | w.pos = offset; |