void Open() { int mode = GetOpenMode(); int siz = GetFileSize(); if(siz == -1){ if(Mode == MMapMode::READ) throw MMapException("can't find file", path_); else mode |= O_CREAT; siz = 0; } size_ = size_ <= 0 ? siz : size_; if((fd_=::open(path_, mode, 0644))== -1){ throw MMapException("open", path_); } if(static_cast<int>(size_ + offset_) > siz){ if(Mode == MMapMode::READ){ size_ = std::max(siz - offset_ ,0UL); }else{ ExpandFile(); } } }
int main(int argc, char *argv[]) { FILE *output; BIT_FILE *input; setbuf( stdout, NULL ); if ( argc < 3 ) usage_exit( argv[ 0 ] ); input = OpenInputBitFile( argv[ 1 ] ); if ( input == NULL ) fatal_error( "Error opening %s for input\n", argv[ 1 ]); output = fopen( argv[ 2 ], "wb" ); if ( output == NULL ) fatal_error( "Error opening %s for output\n", argv[ 2 ]); printf( "\nExpanding %s to %s\n", argv[ 1 ], argv[ 2 ] ); printf( "Using %s\n", CompressionName ); argc -= 3; argv += 3; ExpandFile( input, output, argc, argv ); CloseInputBitFile( input ); fclose( output ); putc( '\n', stdout ); return( 0 ); }