author | ar <ar> | 2004-06-18 19:58:14 (UTC) |
---|---|---|
committer | ar <ar> | 2004-06-18 19:58:14 (UTC) |
commit | d45caef648bce4a73f6f847bc6e9aad125977deb (patch) (side-by-side diff) | |
tree | 2e57aec5300028df4b90b1d07aeabd84e4ebc72f | |
parent | 589dc38a4c44ed7cdd151cf6c136b199ec273398 (diff) | |
download | opie-d45caef648bce4a73f6f847bc6e9aad125977deb.zip opie-d45caef648bce4a73f6f847bc6e9aad125977deb.tar.gz opie-d45caef648bce4a73f6f847bc6e9aad125977deb.tar.bz2 |
- use QFile::encodeName instead of (const char*) or latin1()
- use POSIX rename
-rw-r--r-- | library/filemanager.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/library/filemanager.cpp b/library/filemanager.cpp index 47af1c6..2e5efdd 100644 --- a/library/filemanager.cpp +++ b/library/filemanager.cpp @@ -30,2 +30,3 @@ #include <stdlib.h> +#include <errno.h> #include <sys/stat.h> @@ -65,3 +66,3 @@ bool FileManager::saveFile( const DocLnk &f, const QByteArray &data ) { - qWarning("open failed"); + qWarning( "open failed" ); return FALSE; @@ -71,3 +72,3 @@ bool FileManager::saveFile( const DocLnk &f, const QByteArray &data ) //check if every was written - if ( total_written != int(data.size()) || !f.writeLink() ) + if ( total_written != int( data.size() ) || !f.writeLink() ) { @@ -76,3 +77,3 @@ bool FileManager::saveFile( const DocLnk &f, const QByteArray &data ) } - qDebug("total written %d out of %d", total_written, data.size()); + qDebug( "total written %d out of %d", total_written, data.size() ); @@ -100,3 +101,3 @@ bool FileManager::saveFile( const DocLnk &f, const QString &text ) { - qWarning("open failed"); + qWarning( "open failed" ); return FALSE; @@ -108,3 +109,3 @@ bool FileManager::saveFile( const DocLnk &f, const QString &text ) file.close(); - if ( total_written != int(cstr.length()) || !f.writeLink() ) + if ( total_written != int( cstr.length()) || !f.writeLink() ) { @@ -190,5 +191,5 @@ bool FileManager::copyFile( const AppLnk &src, const AppLnk &dest ) // 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 ); } @@ -196,3 +197,3 @@ bool FileManager::copyFile( const AppLnk &src, const AppLnk &dest ) { - QFile::remove( fileName.latin1() ); + QFile::remove( fileName ); } @@ -243,5 +244,5 @@ bool FileManager::copyFile( const QString & src, const QString & dest ) 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 ); } @@ -253,6 +254,5 @@ 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; @@ -322,6 +322,5 @@ bool FileManager::ensurePathExists( const QString &fn ) { - if ( system(("mkdir -p "+fi.filePath())) ) + if ( system( ("mkdir -p " + QFile::encodeName( fi.filePath() ) ) ) ) return FALSE; } - return TRUE; |