summaryrefslogtreecommitdiff
path: root/library/filemanager.cpp
Side-by-side diff
Diffstat (limited to 'library/filemanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/filemanager.cpp29
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
@@ -29,4 +29,5 @@
/* STD */
#include <stdlib.h>
+#include <errno.h>
#include <sys/stat.h>
@@ -64,5 +65,5 @@ bool FileManager::saveFile( const DocLnk &f, const QByteArray &data )
if ( !file.open( IO_WriteOnly|IO_Raw ) )
{
- qWarning("open failed");
+ qWarning( "open failed" );
return FALSE;
}
@@ -70,10 +71,10 @@ bool FileManager::saveFile( const DocLnk &f, const QByteArray &data )
file.close();
//check if every was written
- if ( total_written != int(data.size()) || !f.writeLink() )
+ if ( total_written != int( data.size() ) || !f.writeLink() )
{
QFile::remove( fileName );
return FALSE;
}
- qDebug("total written %d out of %d", total_written, data.size());
+ qDebug( "total written %d out of %d", total_written, data.size() );
//rename temporary .new file in original filenam
@@ -99,5 +100,5 @@ bool FileManager::saveFile( const DocLnk &f, const QString &text )
if ( !file.open( IO_WriteOnly|IO_Raw ) )
{
- qWarning("open failed");
+ qWarning( "open failed" );
return FALSE;
}
@@ -107,5 +108,5 @@ bool FileManager::saveFile( const DocLnk &f, const QString &text )
total_written = file.writeBlock( cstr.data(), cstr.length() );
file.close();
- if ( total_written != int(cstr.length()) || !f.writeLink() )
+ if ( total_written != int( cstr.length()) || !f.writeLink() )
{
QFile::remove( fileName );
@@ -189,11 +190,11 @@ 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 );
}
else
{
- QFile::remove( fileName.latin1() );
+ QFile::remove( fileName );
}
return ok;
@@ -242,7 +243,7 @@ bool FileManager::copyFile( const QString & src, const QString & dest )
// 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;
@@ -252,8 +253,7 @@ bool FileManager::copyFile( const QString & src, const QString & dest )
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;
}
@@ -321,8 +321,7 @@ bool FileManager::ensurePathExists( const QString &fn )
if ( !fi.exists() )
{
- if ( system(("mkdir -p "+fi.filePath())) )
+ if ( system( ("mkdir -p " + QFile::encodeName( fi.filePath() ) ) ) )
return FALSE;
}
-
return TRUE;
}