@@ -870,7 +870,7 @@ pub enum Chunk {
870870
871871impl Chunk {
872872 pub fn parse < R : Read + Seek > ( r : & mut R ) -> Result < Self > {
873- let start_pos = r. seek ( SeekFrom :: Current ( 0 ) ) ?;
873+ let start_pos = r. stream_position ( ) ?;
874874 let header = ResChunkHeader :: read ( r) ?;
875875 let end_pos = start_pos + header. size as u64 ;
876876 match ChunkType :: from_u16 ( header. ty ) {
@@ -936,7 +936,7 @@ impl Chunk {
936936 strings. push ( s) ;
937937 }
938938 }
939- let pos = r. seek ( SeekFrom :: Current ( 0 ) ) ? as i64 ;
939+ let pos = r. stream_position ( ) ? as i64 ;
940940 if pos % 4 != 0 {
941941 r. seek ( SeekFrom :: Current ( 4 - pos % 4 ) ) ?;
942942 }
@@ -956,15 +956,15 @@ impl Chunk {
956956 tracing:: trace!( "table" ) ;
957957 let table_header = ResTableHeader :: read ( r) ?;
958958 let mut chunks = vec ! [ ] ;
959- while r. seek ( SeekFrom :: Current ( 0 ) ) ? < end_pos {
959+ while r. stream_position ( ) ? < end_pos {
960960 chunks. push ( Chunk :: parse ( r) ?) ;
961961 }
962962 Ok ( Chunk :: Table ( table_header, chunks) )
963963 }
964964 Some ( ChunkType :: Xml ) => {
965965 tracing:: trace!( "xml" ) ;
966966 let mut chunks = vec ! [ ] ;
967- while r. seek ( SeekFrom :: Current ( 0 ) ) ? < end_pos {
967+ while r. stream_position ( ) ? < end_pos {
968968 chunks. push ( Chunk :: parse ( r) ?) ;
969969 }
970970 Ok ( Chunk :: Xml ( chunks) )
@@ -1014,7 +1014,7 @@ impl Chunk {
10141014 tracing:: trace!( "table package" ) ;
10151015 let package_header = ResTablePackageHeader :: read ( r) ?;
10161016 let mut chunks = vec ! [ ] ;
1017- while r. seek ( SeekFrom :: Current ( 0 ) ) ? < end_pos {
1017+ while r. stream_position ( ) ? < end_pos {
10181018 chunks. push ( Chunk :: parse ( r) ?) ;
10191019 }
10201020 Ok ( Chunk :: TablePackage ( package_header, chunks) )
@@ -1067,7 +1067,7 @@ impl Chunk {
10671067 }
10681068 impl ChunkWriter {
10691069 fn start_chunk < W : Seek + Write > ( ty : ChunkType , w : & mut W ) -> Result < Self > {
1070- let start_chunk = w. seek ( SeekFrom :: Current ( 0 ) ) ?;
1070+ let start_chunk = w. stream_position ( ) ?;
10711071 ResChunkHeader :: default ( ) . write ( w) ?;
10721072 Ok ( Self {
10731073 ty,
@@ -1077,13 +1077,13 @@ impl Chunk {
10771077 }
10781078
10791079 fn end_header < W : Seek + Write > ( & mut self , w : & mut W ) -> Result < ( ) > {
1080- self . end_header = w. seek ( SeekFrom :: Current ( 0 ) ) ?;
1080+ self . end_header = w. stream_position ( ) ?;
10811081 Ok ( ( ) )
10821082 }
10831083
10841084 fn end_chunk < W : Seek + Write > ( self , w : & mut W ) -> Result < ( u64 , u64 ) > {
10851085 assert_ne ! ( self . end_header, 0 ) ;
1086- let end_chunk = w. seek ( SeekFrom :: Current ( 0 ) ) ?;
1086+ let end_chunk = w. stream_position ( ) ?;
10871087 let header = ResChunkHeader {
10881088 ty : self . ty as u16 ,
10891089 header_size : ( self . end_header - self . start_chunk ) as u16 ,
@@ -1106,22 +1106,22 @@ impl Chunk {
11061106 for _ in 0 ..indices_count {
11071107 w. write_u32 :: < LittleEndian > ( 0 ) ?;
11081108 }
1109- let strings_start = w. seek ( SeekFrom :: Current ( 0 ) ) ?;
1109+ let strings_start = w. stream_position ( ) ?;
11101110 for string in strings {
1111- indices. push ( w. seek ( SeekFrom :: Current ( 0 ) ) ? - strings_start) ;
1111+ indices. push ( w. stream_position ( ) ? - strings_start) ;
11121112 assert ! ( string. len( ) < 0x7f ) ;
11131113 let chars = string. chars ( ) . count ( ) ;
11141114 w. write_u8 ( chars as u8 ) ?;
11151115 w. write_u8 ( string. len ( ) as u8 ) ?;
11161116 w. write_all ( string. as_bytes ( ) ) ?;
11171117 w. write_u8 ( 0 ) ?;
11181118 }
1119- while w. seek ( SeekFrom :: Current ( 0 ) ) ? % 4 != 0 {
1119+ while w. stream_position ( ) ? % 4 != 0 {
11201120 w. write_u8 ( 0 ) ?;
11211121 }
1122- let styles_start = w. seek ( SeekFrom :: Current ( 0 ) ) ?;
1122+ let styles_start = w. stream_position ( ) ?;
11231123 for style in styles {
1124- indices. push ( w. seek ( SeekFrom :: Current ( 0 ) ) ? - styles_start) ;
1124+ indices. push ( w. stream_position ( ) ? - styles_start) ;
11251125 for span in style {
11261126 span. write ( w) ?;
11271127 }
@@ -1200,18 +1200,18 @@ impl Chunk {
12001200 chunk. end_chunk ( w) ?;
12011201 }
12021202 Chunk :: TablePackage ( package_header, chunks) => {
1203- let package_start = w. seek ( SeekFrom :: Current ( 0 ) ) ?;
1203+ let package_start = w. stream_position ( ) ?;
12041204 let mut chunk = ChunkWriter :: start_chunk ( ChunkType :: TablePackage , w) ?;
12051205 let mut package_header = package_header. clone ( ) ;
1206- let header_start = w. seek ( SeekFrom :: Current ( 0 ) ) ?;
1206+ let header_start = w. stream_position ( ) ?;
12071207 package_header. write ( w) ?;
12081208 chunk. end_header ( w) ?;
12091209
1210- let type_strings_start = w. seek ( SeekFrom :: Current ( 0 ) ) ?;
1210+ let type_strings_start = w. stream_position ( ) ?;
12111211 package_header. type_strings = ( type_strings_start - package_start) as u32 ;
12121212 chunks[ 0 ] . write ( w) ?;
12131213
1214- let key_strings_start = w. seek ( SeekFrom :: Current ( 0 ) ) ?;
1214+ let key_strings_start = w. stream_position ( ) ?;
12151215 package_header. key_strings = ( key_strings_start - package_start) as u32 ;
12161216 chunks[ 1 ] . write ( w) ?;
12171217
@@ -1220,7 +1220,7 @@ impl Chunk {
12201220 }
12211221 chunk. end_chunk ( w) ?;
12221222
1223- let end = w. seek ( SeekFrom :: Current ( 0 ) ) ?;
1223+ let end = w. stream_position ( ) ?;
12241224 w. seek ( SeekFrom :: Start ( header_start) ) ?;
12251225 package_header. write ( w) ?;
12261226 w. seek ( SeekFrom :: Start ( end) ) ?;
0 commit comments