comparison base/TempWriteFile.cpp @ 843:e802e550a1f2

Drop std:: from cout, cerr, endl -- pull these in through Debug.h
author Chris Cannam
date Tue, 26 Nov 2013 13:35:08 +0000
parents b4a8d8221eaf
children 1c9bbbb6116a
comparison
equal deleted inserted replaced
842:23d3a6eca5c3 843:e802e550a1f2
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 << ": " << temp.errorString() << std::endl; 30 cerr << "TempWriteFile: Failed to create temporary file in directory of " << m_target << ": " << temp.errorString() << 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 << " to target " << m_target << std::endl; 63 cerr << "TempWriteFile: Failed to rename temporary file " << m_temp << " to target " << m_target << 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 }