/*! (Re)-creates the temporary file and opens it in \a mode. \internal */ bool recreateTemporaryFile( QIODevice::OpenMode mode ) { deleteTempFile(); bool ok = false; // first try, create it in the target directory tmpFile = createFile( generateTempFileName( filename, false ), mode, permissions, ok, error ); // second try, create it in the temp directory if( tmpFile == 0 ) tmpFile = createFile( generateTempFileName( filename, true ), mode, permissions, ok, error ); if( tmpFile != 0 ) { KDMetaMethodIterator it( QIODevice::staticMetaObject, KDMetaMethodIterator::Signal, KDMetaMethodIterator::IgnoreQObjectMethods ); while( it.hasNext() ) { it.next(); connect( tmpFile, it.connectableSignature(), q, it.connectableSignature() ); } #ifdef Q_OS_WIN makeFileHidden( tmpFile->fileName(), true ); #endif } return tmpFile != 0 && ok; }
void safe_exit(int retVal) { if(restore) { if(tcsetattr(serialportFd, TCSANOW, &old) < 0) { perror("Couldn't restore term attributes"); exit(-1); } } printf("exiting...\n"); registerEvent("exit", ""); closeLogFile(); deleteTempFile(); lockfile_remove(); exit(retVal); }
int main(int argc, char *argv[]) { if (argc < 2) { return error( "usage: [path] [extensions]\n" "\tOR [filename]\n" //"usage: [filenames]\n" //"\tOR [path] -ext [extensions]\n" "Available options are: \n" " -mode EOL mode (unix, dos, mac)\n" " -skiperrors skip any errors when processing files\n" " -nolog hide logs (can increase speed)" // TODO: //" -depth max directory depth (-1 by default)\n" //" -b make backups\n" //" -bext backup extension (\"bak\" by default)\n" //" -bdir backup directory\n" //" -perf output processing time\n" ); } if (processArgs(argc, argv)) return 1; if (!createTempFile()) return error("failed to create a temporary file"); int res = 0; if (SearchFiles) { res = searchRecursive(searchpath, extensions); } else { if (!processFile(searchpath)) res = error("unable to open file"); } deleteTempFile(); return res; }
std::string loadTempFile(const std::string& path, bool remove) { std::string content; std::ifstream output; output.open(path, std::ifstream::binary); if (output.good()) { content.assign((std::istreambuf_iterator<char>(output)), std::istreambuf_iterator<char>()); output.close(); if (remove) { deleteTempFile(path); } return content; } throw std::string("Cannot open file: \"") + path + std::string("\""); }
void BlastQueries::updateTempFile() { deleteTempFile(); //If there aren't any queries, there's no need for a temp file. if (m_queries.size() == 0) return; m_tempFile.open(QIODevice::Append | QIODevice::Text); QTextStream out(&m_tempFile); for (size_t i = 0; i < m_queries.size(); ++i) { out << ">" << m_queries[i].m_name << "\n"; out << m_queries[i].m_sequence; if (i + 1 != m_queries.size()) out << "\n"; } m_tempFile.close(); }
int main (int argc, char *argv[]) { int ret = 0; CString info; #ifdef FOR_ADSP_RELEASE doReadSvnLog(); #endif ret = readFileInfo(info); if (0 != ret) { TRACE(_T("readFileInfo exit -1\n")); return -1; } praseVersionInfo(info); CCreateHeaderFile::createFile(gpVersionInfo); deleteTempFile(); return 0; }
~Private() { deleteTempFile(); }
void BlastQueries::clearQueries() { m_queries.clear(); deleteTempFile(); }
BlastQueries::~BlastQueries() { deleteTempFile(); }