KIOSlave
file.h
Go to the documentation of this file.
00001 /* 00002 Copyright (C) 2000-2002 Stephan Kulow <coolo@kde.org> 00003 Copyright (C) 2000-2002 David Faure <faure@kde.org> 00004 Copyright (C) 2000-2002 Waldo Bastian <bastian@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License (LGPL) as published by the Free Software Foundation; 00009 either version 2 of the License, or (at your option) any later 00010 version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef __file_h__ 00024 #define __file_h__ 00025 00026 #include "kioslave_file_export.h" 00027 #include <kio/global.h> 00028 #include <kio/slavebase.h> 00029 00030 #include <QtCore/QObject> 00031 #include <QtCore/QHash> 00032 00033 00034 #include <sys/types.h> 00035 #include <sys/stat.h> 00036 00037 #include <stdio.h> 00038 #include <unistd.h> 00039 00040 class KIOSLAVE_FILE_EXPORT FileProtocol : public QObject, public KIO::SlaveBase 00041 { 00042 Q_OBJECT 00043 public: 00044 FileProtocol( const QByteArray &pool, const QByteArray &app); 00045 virtual ~FileProtocol(); 00046 00047 virtual void get( const KUrl& url ); 00048 virtual void put( const KUrl& url, int _mode, 00049 KIO::JobFlags _flags ); 00050 virtual void copy( const KUrl &src, const KUrl &dest, 00051 int mode, KIO::JobFlags flags ); 00052 virtual void rename( const KUrl &src, const KUrl &dest, 00053 KIO::JobFlags flags ); 00054 virtual void symlink( const QString &target, const KUrl &dest, 00055 KIO::JobFlags flags ); 00056 00057 virtual void stat( const KUrl& url ); 00058 virtual void listDir( const KUrl& url ); 00059 virtual void mkdir( const KUrl& url, int permissions ); 00060 virtual void chmod( const KUrl& url, int permissions ); 00061 virtual void chown( const KUrl& url, const QString& owner, const QString& group ); 00062 virtual void setModificationTime( const KUrl& url, const QDateTime& mtime ); 00063 virtual void del( const KUrl& url, bool isfile); 00064 virtual void open( const KUrl &url, QIODevice::OpenMode mode ); 00065 virtual void read( KIO::filesize_t size ); 00066 virtual void write( const QByteArray &data ); 00067 virtual void seek( KIO::filesize_t offset ); 00068 virtual void close(); 00069 00075 virtual void special( const QByteArray &data ); 00076 void unmount( const QString& point ); 00077 void mount( bool _ro, const char *_fstype, const QString& dev, const QString& point ); 00078 bool pumount( const QString &point ); 00079 bool pmount( const QString &dev ); 00080 00081 private: 00082 bool createUDSEntry( const QString & filename, const QByteArray & path, KIO::UDSEntry & entry, 00083 short int details, bool withACL ); 00084 int setACL( const char *path, mode_t perm, bool _directoryDefault ); 00085 00086 QString getUserName( uid_t uid ) const; 00087 QString getGroupName( gid_t gid ) const; 00088 00089 bool deleteRecursive(const QString& path); 00090 00091 private: 00092 mutable QHash<uid_t, QString> mUsercache; 00093 mutable QHash<gid_t, QString> mGroupcache; 00094 int openFd; 00095 QString openPath; 00096 }; 00097 00098 #endif
KDE 4.6 API Reference