comparison base/TempDirectory.cpp @ 689:573d45e9487b

Merge from debug-output branch
author Chris Cannam
date Tue, 14 Jun 2011 14:47:59 +0100
parents 06f13a3b9e9e
children 1424aa29ae95
comparison
equal deleted inserted replaced
688:be43b2fe68e8 689:573d45e9487b
42 { 42 {
43 } 43 }
44 44
45 TempDirectory::~TempDirectory() 45 TempDirectory::~TempDirectory()
46 { 46 {
47 std::cerr << "TempDirectory::~TempDirectory" << std::endl; 47 DEBUG << "TempDirectory::~TempDirectory" << endl;
48 48
49 cleanup(); 49 cleanup();
50 } 50 }
51 51
52 void 52 void
206 cleanupDirectory(fi.absoluteFilePath()); 206 cleanupDirectory(fi.absoluteFilePath());
207 } else { 207 } else {
208 if (!QFile(fi.absoluteFilePath()).remove()) { 208 if (!QFile(fi.absoluteFilePath()).remove()) {
209 std::cerr << "WARNING: TempDirectory::cleanup: " 209 std::cerr << "WARNING: TempDirectory::cleanup: "
210 << "Failed to unlink file \"" 210 << "Failed to unlink file \""
211 << fi.absoluteFilePath().toStdString() << "\"" 211 << fi.absoluteFilePath() << "\""
212 << std::endl; 212 << std::endl;
213 } 213 }
214 } 214 }
215 } 215 }
216 216
217 QString dirname = dir.dirName(); 217 QString dirname = dir.dirName();
218 if (dirname != "") { 218 if (dirname != "") {
219 if (!dir.cdUp()) { 219 if (!dir.cdUp()) {
220 std::cerr << "WARNING: TempDirectory::cleanup: " 220 std::cerr << "WARNING: TempDirectory::cleanup: "
221 << "Failed to cd to parent directory of " 221 << "Failed to cd to parent directory of "
222 << tmpdir.toStdString() << std::endl; 222 << tmpdir << std::endl;
223 return; 223 return;
224 } 224 }
225 if (!dir.rmdir(dirname)) { 225 if (!dir.rmdir(dirname)) {
226 std::cerr << "WARNING: TempDirectory::cleanup: " 226 std::cerr << "WARNING: TempDirectory::cleanup: "
227 << "Failed to remove directory " 227 << "Failed to remove directory "
228 << dirname.toStdString() << std::endl; 228 << dirname << std::endl;
229 } 229 }
230 } 230 }
231 231
232 if (isRoot) { 232 if (isRoot) {
233 m_tmpdir = ""; 233 m_tmpdir = "";
246 246
247 QDir subdir(dirpath, "*.pid", QDir::Name, QDir::Files); 247 QDir subdir(dirpath, "*.pid", QDir::Name, QDir::Files);
248 248
249 if (subdir.count() == 0) { 249 if (subdir.count() == 0) {
250 std::cerr << "INFO: Found temporary directory with no .pid file in it!\n(directory=\"" 250 std::cerr << "INFO: Found temporary directory with no .pid file in it!\n(directory=\""
251 << dirpath.toStdString() << "\"). Removing it..." << std::endl; 251 << dirpath << "\"). Removing it..." << std::endl;
252 cleanupDirectory(dirpath); 252 cleanupDirectory(dirpath);
253 std::cerr << "...done." << std::endl; 253 std::cerr << "...done." << std::endl;
254 continue; 254 continue;
255 } 255 }
256 256