summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/filemanager.cpp18
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 )
bool FileManager::renameFile( const QString & src, const QString & dest )
{
if( rename( QFile::encodeName( src ), QFile::encodeName( dest ) ) == -1);
{
- qWarning( "problem renaming file %s to %s, errno: %d", src.latin1(), dest.latin1(), errno );
- return false;
+ if ( errno != 2 && errno != 11 ) //ignore ENOENT and EAGAIN - bug in system?
+ {
+ qWarning( "problem renaming file %s to %s, errno: %d", src.latin1(), dest.latin1(), errno );
+ return false;
+ }
}
return true;
}
/*!
Opens the document specified by \a f as a readable QIODevice.
@@ -308,20 +311,19 @@ QIODevice* FileManager::saveFile( const DocLnk& f )
bool FileManager::exists( const DocLnk &f )
{
return QFile::exists(f.file());
}
/*!
- Ensures that the path \a fn exists, by creating required directories.
+ Ensures that the path \a fileName exists, by creating required directories.
Returns TRUE if successful.
*/
-bool FileManager::ensurePathExists( const QString &fn )
+bool FileManager::ensurePathExists( const QString &fileName )
{
- QFileInfo fi(fn);
- fi.setFile( fi.dirPath(TRUE) );
- if ( !fi.exists() )
+ QDir directory = QFileInfo( fileName ).dir();
+ if ( !directory.exists() )
{
- if ( system( ("mkdir -p " + QFile::encodeName( fi.filePath() ) ) ) )
+ if ( !directory.mkdir( directory.absPath() ) )
return FALSE;
}
return TRUE;
}