Mercurial > hg > forks > UniversalIndentGUI
comparison src/SettingsPaths.cpp @ 699:90002ae3ddc9
Added warning outputs to the temp dir cleanup function and corrected a
comment.
git-svn-id: svn://svn.code.sf.net/p/universalindent/code/trunk@968 59b1889a-e5ac-428c-b0c7-476e01d41282
author | thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282> |
---|---|
date | Tue, 02 Jun 2009 14:35:35 +0000 |
parents | b4aee13bc733 |
children | 3363b7bb0d41 |
comparison
equal
deleted
inserted
replaced
698:3499ddb0f61f | 699:90002ae3ddc9 |
---|---|
225 return portableMode; | 225 return portableMode; |
226 } | 226 } |
227 | 227 |
228 | 228 |
229 /*! | 229 /*! |
230 \brief Returns true if portable mode shall be used. | 230 \brief Completely deletes the created temporary directory with all of its content. |
231 */ | 231 */ |
232 void SettingsPaths::cleanAndRemoveTempDir() { | 232 void SettingsPaths::cleanAndRemoveTempDir() { |
233 QDirIterator dirIterator(tempPath, QDirIterator::Subdirectories); | 233 QDirIterator dirIterator(tempPath, QDirIterator::Subdirectories); |
234 QStack<QString> directoryStack; | 234 QStack<QString> directoryStack; |
235 bool noErrorsOccurred = true; | 235 bool noErrorsOccurred = true; |
243 // There is a path on the stack but the current path doesn't start with that path. | 243 // There is a path on the stack but the current path doesn't start with that path. |
244 // So we changed into another parent directory and the one on the stack can be deleted | 244 // So we changed into another parent directory and the one on the stack can be deleted |
245 // since it must be empty. | 245 // since it must be empty. |
246 if ( !directoryStack.isEmpty() && !currentDirOrFile.startsWith(directoryStack.top()) ) { | 246 if ( !directoryStack.isEmpty() && !currentDirOrFile.startsWith(directoryStack.top()) ) { |
247 QString dirToBeRemoved = directoryStack.pop(); | 247 QString dirToBeRemoved = directoryStack.pop(); |
248 noErrorsOccurred &= QDir(dirToBeRemoved).rmdir(dirToBeRemoved); | 248 bool couldRemoveDir = QDir(dirToBeRemoved).rmdir(dirToBeRemoved); |
249 noErrorsOccurred &= couldRemoveDir; | |
250 if ( couldRemoveDir == false ) | |
251 qWarning() << __LINE__ << " " << __FUNCTION__ << "Could not remove the directory: " << dirToBeRemoved; | |
249 //qDebug() << "Removing Dir " << directoryStack.pop(); | 252 //qDebug() << "Removing Dir " << directoryStack.pop(); |
250 } | 253 } |
251 | 254 |
252 // If the iterator currently points to a directory push it onto the stack. | 255 // If the iterator currently points to a directory push it onto the stack. |
253 if ( dirIterator.fileInfo().isDir() ) { | 256 if ( dirIterator.fileInfo().isDir() ) { |
254 directoryStack.push( currentDirOrFile ); | 257 directoryStack.push( currentDirOrFile ); |
255 //qDebug() << "Pushing onto Stack " << currentDirOrFile; | 258 //qDebug() << "Pushing onto Stack " << currentDirOrFile; |
256 } | 259 } |
257 // otherwise it must be a file, so delete it. | 260 // otherwise it must be a file, so delete it. |
258 else { | 261 else { |
259 noErrorsOccurred &= QFile::remove( currentDirOrFile ); | 262 bool couldRemoveFile = QFile::remove( currentDirOrFile ); |
263 noErrorsOccurred &= couldRemoveFile; | |
264 if ( couldRemoveFile == false ) | |
265 qWarning() << __LINE__ << " " << __FUNCTION__ << "Could not remove the file: " << currentDirOrFile; | |
260 //qDebug() << "Removing File " << currentDirOrFile; | 266 //qDebug() << "Removing File " << currentDirOrFile; |
261 } | 267 } |
262 } | 268 } |
263 } | 269 } |
264 noErrorsOccurred &= QDir(tempPath).rmdir(tempPath); | 270 noErrorsOccurred &= QDir(tempPath).rmdir(tempPath); |
265 //qDebug() << "Removing tempPath " << tempPath; | 271 if ( noErrorsOccurred == false ) |
266 } | 272 qWarning() << __LINE__ << " " << __FUNCTION__ << "While cleaning up the temp dir an error occurred."; |
273 } |