Exemple #1
0
/** write to zzip storage                     also: write(2), zlib(3)
 *
 * This function will write data to a file descriptor. If the file
 * descriptor represents a real file then it will be forwarded to
 * call posix => write(2) directly. If it is a descriptor for a
 * file within a zip directory then the data will be "deflated"
 * using => zlib(3) and appended to the zip archive file.
 */
zzip_ssize_t
zzip_write(ZZIP_FILE * file, const void *ptr, zzip_size_t len)
{
    if (zzip_file_real(file))
        return write(zzip_realfd(file), ptr, len);
    else
        return zzip_file_write(file, ptr, len);
}
Exemple #2
0
bool RasterMapCache::Open(const TCHAR* zfilename) {

    terrain_valid = false;
    if (_tcslen(zfilename)<=0) {
        return false;
    }
    if (!fpTerrain) {
        fpTerrain = zzip_fopen(zfilename, "rb");
        if (!fpTerrain) {
            return false;
        }
        if (!zzip_file_real(fpTerrain)) {
            // don't allow cache mode on files in zip, because way too slow
            zzip_fclose(fpTerrain);
            fpTerrain = NULL;   // was false
            return false;
        };
    }

    DWORD dwBytesRead;
    dwBytesRead = zzip_fread(&TerrainInfo, 1, sizeof(TERRAIN_INFO),
                             fpTerrain);

    if (dwBytesRead != sizeof(TERRAIN_INFO)) {
        Close();
        return false;
    }

    if (!TerrainInfo.StepSize) {
        Close();
        return false;
    }
    terrain_valid = true;
    ClearTerrainCache();
    return terrain_valid;
}