summaryrefslogtreecommitdiff
path: root/library/filemanager.cpp
authorchicken <chicken>2004-03-01 18:10:37 (UTC)
committer chicken <chicken>2004-03-01 18:10:37 (UTC)
commit7fd20d139e2d9bc37ce22bbdb07f4ebc54903f91 (patch) (side-by-side diff)
tree15ef5e3d00c5476ea98ca36ba6c8392eb02e53c8 /library/filemanager.cpp
parent5b4e342004537f84fa53911a46cd00d810378da7 (diff)
downloadopie-7fd20d139e2d9bc37ce22bbdb07f4ebc54903f91.zip
opie-7fd20d139e2d9bc37ce22bbdb07f4ebc54903f91.tar.gz
opie-7fd20d139e2d9bc37ce22bbdb07f4ebc54903f91.tar.bz2
fix includes
Diffstat (limited to 'library/filemanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/filemanager.cpp3
1 files changed, 0 insertions, 3 deletions
diff --git a/library/filemanager.cpp b/library/filemanager.cpp
index 408be20..1e7384e 100644
--- a/library/filemanager.cpp
+++ b/library/filemanager.cpp
@@ -1,123 +1,120 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "filemanager.h"
#include "applnk.h"
-#include <qdir.h>
-#include <qfile.h>
#include <qfileinfo.h>
#include <qtextstream.h>
-#include <qtextcodec.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <dirent.h>
#ifdef Q_OS_MACX
// MacOS X does not have sendfile.. :(
// But maybe in the future.. !?
# ifdef SENDFILE
# include <sys/types.h>
# include <sys/socket.h>
# endif
#else
# include <sys/sendfile.h>
#endif /* Q_OS_MACX */
#include <fcntl.h>
/*!
\class FileManager
\brief The FileManager class assists with AppLnk input/output.
*/
/*!
Constructs a FileManager.
*/
FileManager::FileManager()
{
}
/*!
Destroys a FileManager.
*/
FileManager::~FileManager()
{
}
/*!
Saves \a data as the document specified by \a f.
Returns whether the operation succeeded.
*/
bool FileManager::saveFile( const DocLnk &f, const QByteArray &data )
{
QString fn = f.file() + ".new";
ensurePathExists( fn );
QFile fl( fn );
if ( !fl.open( IO_WriteOnly|IO_Raw ) ) {
qWarning("open failed");
return FALSE;
}
int total_written = fl.writeBlock( data );
fl.close();
if ( total_written != int(data.size()) || !f.writeLink() ) {
QFile::remove( fn );
return FALSE;
}
qDebug("total written %d out of %d", total_written, data.size());
// else rename the file...
if ( !renameFile( fn.latin1(), f.file().latin1() ) ) {
qWarning( "problem renaming file %s to %s, errno: %d", fn.latin1(),
f.file().latin1(), errno );
// remove the file...
}
return TRUE;
}
/*!
Saves \a text as the document specified by \a f.
The text is saved in UTF8 format.
Returns whether the operation succeeded.
*/
bool FileManager::saveFile( const DocLnk &f, const QString &text )
{
QString fn = f.file() + ".new";
ensurePathExists( fn );
QFile fl( fn );
if ( !fl.open( IO_WriteOnly|IO_Raw ) ) {
qWarning("open failed");
return FALSE;
}
QCString cstr = text.utf8();
int total_written;
total_written = fl.writeBlock( cstr.data(), cstr.length() );
fl.close();
if ( total_written != int(cstr.length()) || !f.writeLink() ) {
QFile::remove( fn );
return FALSE;
}
// okay now rename the file..
if ( !renameFile( fn.latin1(), f.file().latin1() ) ) {
qWarning( "problem renaming file %s to %s, errno: %d", fn.latin1(),