Changeset 10076 for OpenSceneGraph/trunk/src/osgPlugins/3ds/chunk.cpp
- Timestamp:
- 04/22/09 17:46:24 (4 years ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osgPlugins/3ds/chunk.cpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgPlugins/3ds/chunk.cpp
r5453 r10076 94 94 */ 95 95 Lib3dsBool 96 lib3ds_chunk_read(Lib3dsChunk *c, FILE *f)97 { 98 ASSERT(c); 99 ASSERT( f);100 c->cur= ftell(f);101 c->chunk=lib3ds_word_read( f);102 c->size=lib3ds_dword_read( f);96 lib3ds_chunk_read(Lib3dsChunk *c, iostream *strm) 97 { 98 ASSERT(c); 99 ASSERT(strm); 100 c->cur=strm->tellg(); 101 c->chunk=lib3ds_word_read(strm); 102 c->size=lib3ds_dword_read(strm); 103 103 c->end=c->cur+c->size; 104 104 c->cur+=6; 105 if (ferror(f) || (c->size<6)) { 105 106 if (strm->fail()||(c->size<6)) { 106 107 return(LIB3DS_FALSE); 107 108 } 108 109 return(LIB3DS_TRUE); 109 110 } 111 112 113 /*! 114 * \ingroup chunk 115 */ 116 Lib3dsBool 117 lib3ds_chunk_read_start(Lib3dsChunk *c, Lib3dsWord chunk, FILE *f) 118 { 119 ASSERT(c); 120 ASSERT(f); 121 if (!lib3ds_chunk_read(c, f)) { 110 } 111 112 113 /*! 114 * \ingroup chunk 115 */ 116 Lib3dsBool 117 lib3ds_chunk_read_start(Lib3dsChunk *c, Lib3dsWord chunk, iostream *strm) 118 { 119 ASSERT(c); 120 ASSERT(strm); 121 if (!lib3ds_chunk_read(c, strm)) { 122 122 return(LIB3DS_FALSE); 123 123 } … … 131 131 */ 132 132 void 133 lib3ds_chunk_read_tell(Lib3dsChunk *c, FILE *f)134 { 135 c->cur=ftell(f);133 lib3ds_chunk_read_tell(Lib3dsChunk *c, iostream *strm) 134 { 135 c->cur=strm->tellg(); 136 136 } 137 137 … … 141 141 */ 142 142 Lib3dsWord 143 lib3ds_chunk_read_next(Lib3dsChunk *c, FILE *f)143 lib3ds_chunk_read_next(Lib3dsChunk *c, iostream *strm) 144 144 { 145 145 Lib3dsChunk d; … … 150 150 } 151 151 152 fseek(f, (long)c->cur, SEEK_SET);153 d.chunk=lib3ds_word_read( f);154 d.size=lib3ds_dword_read( f);152 strm->seekg((long)c->cur,ios_base::beg); 153 d.chunk=lib3ds_word_read(strm); 154 d.size=lib3ds_dword_read(strm); 155 155 lib3ds_chunk_debug_dump(&d); 156 156 c->cur+=d.size; … … 163 163 */ 164 164 void 165 lib3ds_chunk_read_reset(Lib3dsChunk *, FILE *f)166 { 167 fseek(f, -6, SEEK_CUR);168 } 169 170 171 /*! 172 * \ingroup chunk 173 */ 174 void 175 lib3ds_chunk_read_end(Lib3dsChunk *c, FILE *f)165 lib3ds_chunk_read_reset(Lib3dsChunk *, iostream *strm) 166 { 167 strm->seekg(-6,ios_base::cur); 168 } 169 170 171 /*! 172 * \ingroup chunk 173 */ 174 void 175 lib3ds_chunk_read_end(Lib3dsChunk *c, iostream *strm) 176 176 { 177 177 lib3ds_chunk_debug_leave(c); 178 fseek(f, c->end, SEEK_SET);178 strm->seekg(c->end,ios_base::beg); 179 179 } 180 180 … … 191 191 */ 192 192 Lib3dsBool 193 lib3ds_chunk_write(Lib3dsChunk *c, FILE *f)194 { 195 ASSERT(c); 196 if (!lib3ds_word_write(c->chunk, f)) {193 lib3ds_chunk_write(Lib3dsChunk *c, iostream *strm) 194 { 195 ASSERT(c); 196 if (!lib3ds_word_write(c->chunk, strm)) { 197 197 LIB3DS_ERROR_LOG; 198 198 return(LIB3DS_FALSE); 199 199 } 200 if (!lib3ds_dword_write(c->size, f)) {200 if (!lib3ds_dword_write(c->size, strm)) { 201 201 LIB3DS_ERROR_LOG; 202 202 return(LIB3DS_FALSE); … … 210 210 */ 211 211 Lib3dsBool 212 lib3ds_chunk_write_start(Lib3dsChunk *c, FILE *f)212 lib3ds_chunk_write_start(Lib3dsChunk *c, iostream *strm) 213 213 { 214 214 ASSERT(c); 215 215 c->size=0; 216 c->cur= ftell(f);217 if (!lib3ds_word_write(c->chunk, f)) {218 return(LIB3DS_FALSE); 219 } 220 if (!lib3ds_dword_write(c->size, f)) {216 c->cur=strm->tellp(); 217 if (!lib3ds_word_write(c->chunk, strm)) { 218 return(LIB3DS_FALSE); 219 } 220 if (!lib3ds_dword_write(c->size, strm)) { 221 221 return(LIB3DS_FALSE); 222 222 } … … 229 229 */ 230 230 Lib3dsBool 231 lib3ds_chunk_write_end(Lib3dsChunk *c, FILE *f)232 { 233 ASSERT(c); 234 c->size= ftell(f) - c->cur;235 fseek(f, c->cur+2, SEEK_SET);236 if (!lib3ds_dword_write(c->size, f)) {231 lib3ds_chunk_write_end(Lib3dsChunk *c, iostream *strm) 232 { 233 ASSERT(c); 234 c->size=(Lib3dsDword)(strm->tellp()) - c->cur; 235 strm->seekp(c->cur+2,ios_base::beg); 236 if (!lib3ds_dword_write(c->size, strm)) { 237 237 LIB3DS_ERROR_LOG; 238 238 return(LIB3DS_FALSE); … … 240 240 241 241 c->cur+=c->size; 242 fseek(f, c->cur, SEEK_SET);243 if ( ferror(f)) {242 strm->seekp(c->cur, ios_base::beg); 243 if (strm->fail()) { 244 244 LIB3DS_ERROR_LOG; 245 245 return(LIB3DS_FALSE);
