Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8362 in orxonox.OLD for trunk/src/lib/network/zip.cc


Ignore:
Timestamp:
Jun 14, 2006, 10:08:41 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: removed stupid included in base_object.h
this should lead to faster compile-times

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/network/zip.cc

    r7954 r8362  
    1717
    1818#include "src/lib/util/loading/resource_manager.h"
     19#include "debug.h"
    1920
    2021/**
     
    5455  fileName = fileName + "/dicts/" + name;
    5556  //PRINTF(0)("filename: %s\n", fileName.c_str());
    56  
     57
    5758  FILE * f = fopen( fileName.c_str(), "r" );
    58  
     59
    5960  if ( !f )
    6061  {
     
    6263    return false;
    6364  }
    64  
     65
    6566  byte buf[1024];
    66  
     67
    6768  int nBytesRead = 0;
    68  
     69
    6970  while ( !feof( f ) )
    7071  {
    7172    nBytesRead += fread( buf, 1, sizeof(buf), f );
    7273  }
    73  
     74
    7475  DictionaryEntry entry;
    75  
     76
    7677  entry.dictLen = nBytesRead;
    7778  entry.dict = new Byte[nBytesRead];
    78  
     79
    7980  fseek( f, 0, SEEK_SET );
    80  
     81
    8182  assert( fread( entry.dict, 1, nBytesRead, f ) == nBytesRead );
    82  
     83
    8384  entry.adler = adler32( adler32( 0L, Z_NULL, 0 ), entry.dict, nBytesRead );
    84  
     85
    8586  dicts.push_back( entry );
    86  
     87
    8788  PRINTF(3)("Loaded dictionary '%s' with adler = %d\n", name.c_str(), entry.adler );
    88  
     89
    8990  return true;
    9091}
     
    106107    return -1;
    107108  }
    108  
     109
    109110  int res;
    110111
     
    124125
    125126  res = deflateSetDictionary( &strm, (Bytef*)(dicts[dict].dict), dicts[dict].dictLen );
    126        
     127
    127128  if ( res != Z_OK )
    128129  {
     
    139140
    140141  res = deflate( &strm, Z_FINISH );
    141        
     142
    142143  if ( res != Z_STREAM_END )
    143144  {
     
    152153
    153154  res = deflateEnd( &strm );
    154        
     155
    155156  if ( res != Z_OK )
    156157  {
     
    161162    else
    162163      PRINTF(1)("deflateEnd error: dont know\n");
    163    
    164     return -1;
    165   }
    166  
     164
     165    return -1;
     166  }
     167
    167168  return zippedlen;
    168169
     
    181182  z_stream strm;
    182183  int res = 0;
    183  
     184
    184185  strm.zalloc = Z_NULL;
    185186  strm.zfree = Z_NULL;
     
    193194    return -1;
    194195  }
    195        
     196
    196197  strm.next_out = (Bytef*)to;
    197198  strm.avail_out = maxLength;
     
    202203
    203204  assert( inflate( &strm, Z_NO_FLUSH ) == Z_NEED_DICT );
    204        
     205
    205206  int dictId = -1;
    206  
     207
    207208  for ( int i = 0; i < dicts.size(); i++ )
    208209  {
     
    213214    }
    214215  }
    215  
     216
    216217  if ( dictId == -1 )
    217218  {
     
    219220    return -1;
    220221  }
    221      
     222
    222223  res = inflateSetDictionary( &strm, (Bytef*)dicts[dictId].dict, dicts[dictId].dictLen );
    223        
     224
    224225  if ( res != Z_OK )
    225226  {
     
    230231
    231232  res = inflate( &strm, Z_FINISH );
    232        
     233
    233234  if ( res != Z_STREAM_END )
    234235  {
     
    243244
    244245  res = inflateEnd( &strm );
    245        
     246
    246247  if ( res != Z_OK )
    247248  {
     
    249250    return -1;
    250251  }
    251  
     252
    252253  return unzippedlen;
    253254}
Note: See TracChangeset for help on using the changeset viewer.