-rw-r--r-- | library/filemanager.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/library/filemanager.cpp b/library/filemanager.cpp index 47af1c6..2e5efdd 100644 --- a/library/filemanager.cpp +++ b/library/filemanager.cpp @@ -25,12 +25,13 @@ #include <qdir.h> #include <qfileinfo.h> #include <qtextstream.h> /* STD */ #include <stdlib.h> +#include <errno.h> #include <sys/stat.h> /*! \class FileManager \brief The FileManager class assists with AppLnk input/output. */ @@ -185,19 +186,19 @@ bool FileManager::copyFile( const AppLnk &src, const AppLnk &dest ) if ( ok ) ok = dest.writeLink(); if ( ok ) { // okay now rename the file... - if ( !renameFile( fileName.latin1(), dest.file().latin1() ) ) + if ( !renameFile( fileName, dest.file() ) ) // remove the tmp file, otherwise, it will just lay around... - QFile::remove( fileName.latin1() ); + QFile::remove( fileName ); } else { - QFile::remove( fileName.latin1() ); + QFile::remove( fileName ); } return ok; } bool FileManager::copyFile( const QString & src, const QString & dest ) { @@ -238,26 +239,25 @@ bool FileManager::copyFile( const QString & src, const QString & dest ) } } srcFile.close(); destFile.close(); // Set file permissions struct stat status; - if( stat( (const char *) src, &status ) == 0 ) + if( stat( QFile::encodeName( src ), &status ) == 0 ) { - chmod( (const char *) dest, status.st_mode ); + chmod( QFile::encodeName( dest ), status.st_mode ); } return ok; } bool FileManager::renameFile( const QString & src, const QString & dest ) { - QDir dir( QFileInfo( src ).absFilePath() ); - if ( !dir.rename( src, dest ) ) + if( rename( QFile::encodeName( src ), QFile::encodeName( dest ) ) == -1); { - qWarning( "problem renaming file %s to %s", src, dest ); + qWarning( "problem renaming file %s to %s, errno: %d", src.latin1(), dest.latin1(), errno ); return false; } return true; } /*! @@ -317,12 +317,11 @@ bool FileManager::exists( const DocLnk &f ) bool FileManager::ensurePathExists( const QString &fn ) { QFileInfo fi(fn); fi.setFile( fi.dirPath(TRUE) ); if ( !fi.exists() ) { - if ( system(("mkdir -p "+fi.filePath())) ) + if ( system( ("mkdir -p " + QFile::encodeName( fi.filePath() ) ) ) ) return FALSE; } - return TRUE; } |