MCPcopy Index your code
hub / github.com/Audio4Linux/JDSP4Linux / overwriteFile

Method overwriteFile

3rdparty/qtcsv-qt5/sources/writer.cpp:98–134  ·  view source on GitHub ↗

Overwrite file with new information @input: - filePath - string with absolute path to csv-file - content - not empty handler of content for csv-file - codec - pointer to codec object that would be used for file writing @output: - bool - True if file was overwritten with new data, otherwise False

Source from the content-addressed store, hash-verified

96// @output:
97// - bool - True if file was overwritten with new data, otherwise False
98bool WriterPrivate::overwriteFile(
99 const QString& filePath,
100 ContentIterator& content,
101 QTextCodec* codec)
102{
103 // Create path to the unique temporary file
104 QString tempFileName = getTempFileName();
105 if (tempFileName.isEmpty())
106 {
107 qDebug() << __FUNCTION__ <<
108 "Error - failed to create unique name for temp file";
109 return false;
110 }
111
112 TempFileHandler handler(tempFileName);
113
114 // Write information to the temporary file
115 if (false == appendToFile(tempFileName, content, codec)) { return false; }
116
117 // Remove "old" file if it exists
118 if (QFile::exists(filePath) && false == QFile::remove(filePath))
119 {
120 qDebug() << __FUNCTION__ << "Error - failed to remove file" << filePath;
121 return false;
122 }
123
124 // Copy "new" file (temporary file) to the destination path (replace
125 // "old" file)
126 if (false == QFile::copy(tempFileName, filePath))
127 {
128 qDebug() << __FUNCTION__ <<
129 "Error - failed to copy temp file to" << filePath;
130 return false;
131 }
132
133 return true;
134}
135
136// Write csv data to IO Device
137// @input:

Callers

nothing calls this directly

Calls 1

isEmptyMethod · 0.45

Tested by

no test coverage detected