comparison base/TempWriteFile.cpp @ 686:b4a8d8221eaf debug-output

Remove most toStdString calls (no longer needed, with debug header)
author Chris Cannam
date Thu, 12 May 2011 17:31:24 +0100
parents 341e4e1a6ed3
children e802e550a1f2
comparison
equal deleted inserted replaced
685:99222d4bfc78 686:b4a8d8221eaf
25 { 25 {
26 QTemporaryFile temp(m_target + "."); 26 QTemporaryFile temp(m_target + ".");
27 temp.setAutoRemove(false); 27 temp.setAutoRemove(false);
28 temp.open(); // creates the file and opens it atomically 28 temp.open(); // creates the file and opens it atomically
29 if (temp.error()) { 29 if (temp.error()) {
30 std::cerr << "TempWriteFile: Failed to create temporary file in directory of " << m_target.toStdString() << ": " << temp.errorString().toStdString() << std::endl; 30 std::cerr << "TempWriteFile: Failed to create temporary file in directory of " << m_target << ": " << temp.errorString() << std::endl;
31 throw FileOperationFailed(temp.fileName(), "creation"); 31 throw FileOperationFailed(temp.fileName(), "creation");
32 } 32 }
33 33
34 m_temp = temp.fileName(); 34 m_temp = temp.fileName();
35 temp.close(); // does not remove the file 35 temp.close(); // does not remove the file
58 // According to http://doc.trolltech.com/4.4/qdir.html#rename 58 // According to http://doc.trolltech.com/4.4/qdir.html#rename
59 // some systems fail, if renaming over an existing file. 59 // some systems fail, if renaming over an existing file.
60 // Therefore, delete first the existing file. 60 // Therefore, delete first the existing file.
61 if (dir.exists(m_target)) dir.remove(m_target); 61 if (dir.exists(m_target)) dir.remove(m_target);
62 if (!dir.rename(m_temp, m_target)) { 62 if (!dir.rename(m_temp, m_target)) {
63 std::cerr << "TempWriteFile: Failed to rename temporary file " << m_temp.toStdString() << " to target " << m_target.toStdString() << std::endl; 63 std::cerr << "TempWriteFile: Failed to rename temporary file " << m_temp << " to target " << m_target << std::endl;
64 throw FileOperationFailed(m_temp, "rename"); 64 throw FileOperationFailed(m_temp, "rename");
65 } 65 }
66 66
67 m_temp = ""; 67 m_temp = "";
68 } 68 }