-rw-r--r-- | library/filemanager.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/library/filemanager.cpp b/library/filemanager.cpp index 2e5efdd..fbfa1d9 100644 --- a/library/filemanager.cpp +++ b/library/filemanager.cpp | |||
@@ -251,14 +251,17 @@ bool FileManager::copyFile( const QString & src, const QString & dest ) | |||
251 | 251 | ||
252 | 252 | ||
253 | bool FileManager::renameFile( const QString & src, const QString & dest ) | 253 | bool FileManager::renameFile( const QString & src, const QString & dest ) |
254 | { | 254 | { |
255 | if( rename( QFile::encodeName( src ), QFile::encodeName( dest ) ) == -1); | 255 | if( rename( QFile::encodeName( src ), QFile::encodeName( dest ) ) == -1); |
256 | { | 256 | { |
257 | qWarning( "problem renaming file %s to %s, errno: %d", src.latin1(), dest.latin1(), errno ); | 257 | if ( errno != 2 && errno != 11 ) //ignore ENOENT and EAGAIN - bug in system? |
258 | return false; | 258 | { |
259 | qWarning( "problem renaming file %s to %s, errno: %d", src.latin1(), dest.latin1(), errno ); | ||
260 | return false; | ||
261 | } | ||
259 | } | 262 | } |
260 | return true; | 263 | return true; |
261 | } | 264 | } |
262 | 265 | ||
263 | /*! | 266 | /*! |
264 | Opens the document specified by \a f as a readable QIODevice. | 267 | Opens the document specified by \a f as a readable QIODevice. |
@@ -308,20 +311,19 @@ QIODevice* FileManager::saveFile( const DocLnk& f ) | |||
308 | bool FileManager::exists( const DocLnk &f ) | 311 | bool FileManager::exists( const DocLnk &f ) |
309 | { | 312 | { |
310 | return QFile::exists(f.file()); | 313 | return QFile::exists(f.file()); |
311 | } | 314 | } |
312 | 315 | ||
313 | /*! | 316 | /*! |
314 | Ensures that the path \a fn exists, by creating required directories. | 317 | Ensures that the path \a fileName exists, by creating required directories. |
315 | Returns TRUE if successful. | 318 | Returns TRUE if successful. |
316 | */ | 319 | */ |
317 | bool FileManager::ensurePathExists( const QString &fn ) | 320 | bool FileManager::ensurePathExists( const QString &fileName ) |
318 | { | 321 | { |
319 | QFileInfo fi(fn); | 322 | QDir directory = QFileInfo( fileName ).dir(); |
320 | fi.setFile( fi.dirPath(TRUE) ); | 323 | if ( !directory.exists() ) |
321 | if ( !fi.exists() ) | ||
322 | { | 324 | { |
323 | if ( system( ("mkdir -p " + QFile::encodeName( fi.filePath() ) ) ) ) | 325 | if ( !directory.mkdir( directory.absPath() ) ) |
324 | return FALSE; | 326 | return FALSE; |
325 | } | 327 | } |
326 | return TRUE; | 328 | return TRUE; |
327 | } | 329 | } |