Changeset 8362 in orxonox.OLD for trunk/src/lib/network/zip.cc
- Timestamp:
- Jun 14, 2006, 10:08:41 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/network/zip.cc
r7954 r8362 17 17 18 18 #include "src/lib/util/loading/resource_manager.h" 19 #include "debug.h" 19 20 20 21 /** … … 54 55 fileName = fileName + "/dicts/" + name; 55 56 //PRINTF(0)("filename: %s\n", fileName.c_str()); 56 57 57 58 FILE * f = fopen( fileName.c_str(), "r" ); 58 59 59 60 if ( !f ) 60 61 { … … 62 63 return false; 63 64 } 64 65 65 66 byte buf[1024]; 66 67 67 68 int nBytesRead = 0; 68 69 69 70 while ( !feof( f ) ) 70 71 { 71 72 nBytesRead += fread( buf, 1, sizeof(buf), f ); 72 73 } 73 74 74 75 DictionaryEntry entry; 75 76 76 77 entry.dictLen = nBytesRead; 77 78 entry.dict = new Byte[nBytesRead]; 78 79 79 80 fseek( f, 0, SEEK_SET ); 80 81 81 82 assert( fread( entry.dict, 1, nBytesRead, f ) == nBytesRead ); 82 83 83 84 entry.adler = adler32( adler32( 0L, Z_NULL, 0 ), entry.dict, nBytesRead ); 84 85 85 86 dicts.push_back( entry ); 86 87 87 88 PRINTF(3)("Loaded dictionary '%s' with adler = %d\n", name.c_str(), entry.adler ); 88 89 89 90 return true; 90 91 } … … 106 107 return -1; 107 108 } 108 109 109 110 int res; 110 111 … … 124 125 125 126 res = deflateSetDictionary( &strm, (Bytef*)(dicts[dict].dict), dicts[dict].dictLen ); 126 127 127 128 if ( res != Z_OK ) 128 129 { … … 139 140 140 141 res = deflate( &strm, Z_FINISH ); 141 142 142 143 if ( res != Z_STREAM_END ) 143 144 { … … 152 153 153 154 res = deflateEnd( &strm ); 154 155 155 156 if ( res != Z_OK ) 156 157 { … … 161 162 else 162 163 PRINTF(1)("deflateEnd error: dont know\n"); 163 164 return -1; 165 } 166 164 165 return -1; 166 } 167 167 168 return zippedlen; 168 169 … … 181 182 z_stream strm; 182 183 int res = 0; 183 184 184 185 strm.zalloc = Z_NULL; 185 186 strm.zfree = Z_NULL; … … 193 194 return -1; 194 195 } 195 196 196 197 strm.next_out = (Bytef*)to; 197 198 strm.avail_out = maxLength; … … 202 203 203 204 assert( inflate( &strm, Z_NO_FLUSH ) == Z_NEED_DICT ); 204 205 205 206 int dictId = -1; 206 207 207 208 for ( int i = 0; i < dicts.size(); i++ ) 208 209 { … … 213 214 } 214 215 } 215 216 216 217 if ( dictId == -1 ) 217 218 { … … 219 220 return -1; 220 221 } 221 222 222 223 res = inflateSetDictionary( &strm, (Bytef*)dicts[dictId].dict, dicts[dictId].dictLen ); 223 224 224 225 if ( res != Z_OK ) 225 226 { … … 230 231 231 232 res = inflate( &strm, Z_FINISH ); 232 233 233 234 if ( res != Z_STREAM_END ) 234 235 { … … 243 244 244 245 res = inflateEnd( &strm ); 245 246 246 247 if ( res != Z_OK ) 247 248 { … … 249 250 return -1; 250 251 } 251 252 252 253 return unzippedlen; 253 254 }
Note: See TracChangeset
for help on using the changeset viewer.