Show
Ignore:
Timestamp:
03/22/10 14:13:22 (4 years ago)
Author:
robert
Message:

From Chuck Seberino, "have a fix for the reading code in trunk/src/osgPlugins/gz/ReaderWriterGZ.cpp. It seems that the std::istream::readsome method on windows is a no-op (for files. After much head scratching and research I was able to figure out what was going on. I am submitting a fix to replace readsome with read() and gcount(). This change is for all platforms. The previous implementation works fine under linux and OSX, so if you would rather keep things the way they are you can just #ifdef for non-WIN32.

I also added openmode flags to the ifstream constructor, since they were needed to get proper reading as well as a typo fix."

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgPlugins/gz/ReaderWriterGZ.cpp

    r10465 r11272  
    174174    local_opt->getDatabasePathList().push_front(osgDB::getFilePath(fileName)); 
    175175 
    176     std::ifstream fin(fileName.c_str()); 
     176    std::ifstream fin(fileName.c_str(), std::ios::binary|std::ios::in); 
    177177    if (!fin) return ReadResult::ERROR_IN_READING_FILE; 
    178178     
     
    252252    strm.next_in = Z_NULL; 
    253253    ret = inflateInit2(&strm, 
    254                        15 + 32 // autodected zlib or gzip header 
     254                       15 + 32 // autodetected zlib or gzip header 
    255255                       ); 
    256256    if (ret != Z_OK) 
     
    260260    do { 
    261261 
    262         strm.avail_in = fin.readsome((char*)in, CHUNK); 
     262        fin.read((char*)in, CHUNK); 
     263        strm.avail_in = fin.gcount(); 
    263264 
    264265        if (fin.fail())