示例#1
0
    /*!
     (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;
    }
示例#2
0
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);
}
示例#3
0
文件: Main.cpp 项目: gigte/nlfix
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;
}
示例#4
0
文件: Common.cpp 项目: spajak/cef-pdf
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("\"");
}
示例#5
0
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();
}
示例#6
0
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;
}
示例#7
0
 ~Private()
 {
     deleteTempFile();
 }
示例#8
0
void BlastQueries::clearQueries()
{
    m_queries.clear();
    deleteTempFile();
}
示例#9
0
BlastQueries::~BlastQueries()
{
    deleteTempFile();
}