// Strip the leading directories and // the last trailling suffix from a filename std::string stripFilename(const std::string& filename) { std::string out = stripDirectories(filename); // Remove the gzip extension if necessary if(isGzip(out)) out = stripExtension(out); return stripExtension(out); }
// Open a file that may or may not be gzipped for reading // The caller is responsible for freeing the handle std::istream* createReader(const std::string& filename, std::ios_base::openmode mode) { if(isGzip(filename)) { igzstream* pGZ = new igzstream(filename.c_str(), mode); assertGZOpen(*pGZ, filename); return pGZ; } else { std::ifstream* pReader = new std::ifstream(filename.c_str(), mode); assertFileOpen(*pReader, filename); return pReader; } }
int KProtocolTAR::AttachTAR( const char *_command ) { // debug("KProtocolTAR::AttachTAR(command=%s)",_command); InitParent(); int bGzip = isGzip(); if (bGzip == FAIL) return FAIL; KURL uparent( ParentURL ); if( Parent->Open( &uparent, READ ) == FAIL ) return Error(KIO_ERROR_CouldNotRead, "could not read",0) ; QString cmd; // GZIP file ? if ( bGzip ) cmd.sprintf( _command, "z" ); else cmd.sprintf( _command, "" ); if( Slave.Start( cmd ) == FAIL ) return Error(KIO_ERROR_CouldNotRead, "could not read",0) ; Slave.SetNDelay(KSlave::IN | KSlave::OUT | KSlave::ERR); return SUCCESS; }