/* void openFiles() * Opens the files to run the program. */ void openFiles(char* outFile, File* out, char* primFile, FILE** prim, char* inFile, File* in, char* logFile, FILE** log, char* bedFile, FILE** bed, char* wasteFile, File* waste, char* corrFile, File* corr, int gz) { // open required files *prim = openRead(primFile); if (gz) { // gzip compressed files in->gzf = gzopen(inFile, "r"); if (in->gzf == NULL) exit(error(inFile, ERROPEN)); openGZWrite(outFile, out, gz); } else { in->f = openRead(inFile); out->f = openWrite(outFile); } // open optional files if (bedFile != NULL) *bed = openRead(bedFile); if (logFile != NULL) *log = openWrite(logFile); if (wasteFile != NULL) openGZWrite(wasteFile, waste, gz); if (corrFile != NULL) openGZWrite(corrFile, corr, gz); }
int TLKFile::write(std::string fname) { if(openWrite(fname)) return errcode; if(finalWrite()) return errcode; close(); return errcode = 0; }
int TLKFile::write(uint8 **mem, uint32 *size) { if(openWrite()) return errcode; if(finalWrite()) return errcode; if(mem) *mem = getMem(); if(size) *size = getMemSize(); close(); return errcode = 0; }
bool File::openAppend() { bool isopen = openWrite(); if(isopen) outStream->seekp(this->getSize()); return isopen; }
struct pipeline *pipelineOpen(char ***cmds, unsigned opts, char *otherEndFile, char *stderrFile) /* Create a pipeline from an array of commands. See pipeline.h for * full documentation */ { int otherEndFd; int stderrFd = (stderrFile == NULL) ? STDERR_FILENO : openWrite(stderrFile); checkOpts(opts); if (opts & pipelineRead) otherEndFd = (otherEndFile == NULL) ? STDIN_FILENO : openRead(otherEndFile); else otherEndFd = (otherEndFile == NULL) ? STDOUT_FILENO : openWrite(otherEndFile); struct pipeline *pl = pipelineOpenFd(cmds, opts, otherEndFd, stderrFd); safeClose(&otherEndFd); if (stderrFile != NULL) safeClose(&stderrFd); return pl; }
/* void openFiles() * Open input and output files. */ void openFiles(char* outFile, File* out, char* inFile, File* in, int gz) { if (gz) { in->gzf = gzopen(inFile, "r"); if (in->gzf == NULL) exit(error(inFile, ERROPEN)); } else { in->f = fopen(inFile, "r"); if (in->f == NULL) exit(error(inFile, ERROPEN)); } openWrite(outFile, out, gz); }
bool KoStore::open( const QString & _name ) { // This also converts from relative to absolute, i.e. merges the currentPath() m_sName = toExternalNaming( _name ); if ( m_bIsOpen ) { kdWarning(s_area) << "KoStore: File is already opened" << endl; //return KIO::ERR_INTERNAL; return false; } if ( m_sName.length() > 512 ) { kdError(s_area) << "KoStore: Filename " << m_sName << " is too long" << endl; //return KIO::ERR_MALFORMED_URL; return false; } if ( m_mode == Write ) { kdDebug(s_area) << "KoStore: opening for writing '" << m_sName << "'" << endl; if ( m_strFiles.findIndex( m_sName ) != -1 ) // just check if it's there { kdWarning(s_area) << "KoStore: Duplicate filename " << m_sName << endl; //return KIO::ERR_FILE_ALREADY_EXIST; return false; } m_strFiles.append( m_sName ); m_iSize = 0; if ( !openWrite( m_sName ) ) return false; } else if ( m_mode == Read ) { kdDebug(s_area) << "Opening for reading '" << m_sName << "'" << endl; if ( !openRead( m_sName ) ) return false; } else //return KIO::ERR_UNSUPPORTED_ACTION; return false; m_bIsOpen = true; return true; }
/* void openGZWrite() * Open a (possibly gzip compressed) file for writing. */ void openGZWrite(char* outFile, File* out, int gz) { if (gz) { if (!strcmp(outFile + strlen(outFile) - strlen(GZEXT), GZEXT)) out->gzf = gzopen(outFile, "w"); else { // add ".gz" to outFile char* outFile2 = memalloc(strlen(outFile) + strlen(GZEXT) + 1); strcpy(outFile2, outFile); strcat(outFile2, GZEXT); out->gzf = gzopen(outFile2, "w"); free(outFile2); } if (out->gzf == NULL) exit(error(outFile, ERROPENW)); } else out->f = openWrite(outFile); }
bool KoStore::open(const QString & _name) { Q_D(KoStore); // This also converts from relative to absolute, i.e. merges the currentPath() d->fileName = d->toExternalNaming(_name); if (d->isOpen) { kWarning(30002) << "Store is already opened, missing close"; //return KIO::ERR_INTERNAL; return false; } if (d->fileName.length() > 512) { kError(30002) << "KoStore: Filename " << d->fileName << " is too long" << endl; //return KIO::ERR_MALFORMED_URL; return false; } if (d->mode == Write) { kDebug(30002) << "opening for writing" << d->fileName; if (d->filesList.contains(d->fileName)) { kWarning(30002) << "KoStore: Duplicate filename" << d->fileName; //return KIO::ERR_FILE_ALREADY_EXIST; return false; } d->filesList.append(d->fileName); d->size = 0; if (!openWrite(d->fileName)) return false; } else if (d->mode == Read) { kDebug(30002) << "Opening for reading" << d->fileName; if (!openRead(d->fileName)) return false; } else //return KIO::ERR_UNSUPPORTED_ACTION; return false; d->isOpen = true; return true; }
// openFiles void openFiles(char* outFile, FILE** out, char* dupFile, FILE** dup) { *out = openWrite(outFile); if (dupFile != NULL) *dup = openWrite(dupFile); }
int GFFFile::beginWrite(void) { if(openWrite()) return errcode; return errcode = 0; }
int GFFFile::beginWrite(std::string fname) { if(openWrite(fname)) return errcode; return errcode = 0; }
static inline WriteFile* openWrite(const std::string& filename) { return openWrite(filename.c_str()); }
int ERFFile::beginWrite(uint32 n, ExoLocString *descr) { if(openWrite()) return errcode; if((n && descr) && writePronto(n, *descr)) return errcode; return errcode = 0; }
axStatus axFile::openWrite ( const char *filename, bool create_if_file_not_exists, bool truncate ) { axTempStringW tmp; axStatus st = tmp.set( filename ); if( !st ) return st; return openWrite ( tmp, create_if_file_not_exists, truncate ); }