00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00020 #ifndef flc_vfs_provider_H
00021 #define flc_vfs_provider_H
00022
00023 #include <falcon/setup.h>
00024 #include <falcon/basealloc.h>
00025 #include <falcon/filestat.h>
00026 #include <falcon/dir_sys.h>
00027 #include <falcon/string.h>
00028 #include <falcon/uri.h>
00029
00030 namespace Falcon {
00031
00032 class Error;
00033
00047 class FALCON_DYN_CLASS VFSProvider: public BaseAlloc
00048 {
00049 String m_servedProto;
00050
00051 protected:
00052 VFSProvider( const String &name ):
00053 m_servedProto( name )
00054 {}
00055
00056 public:
00057 virtual ~VFSProvider();
00058
00064 class OParams {
00065 uint32 m_oflags;
00066 uint32 m_shflags;
00067 friend class VSFProvider;
00068
00069 public:
00070 OParams():
00071 m_oflags(0),
00072 m_shflags(0)
00073 {}
00074
00075 OParams& rdOnly() { m_oflags |= 0x1; return *this; }
00076 bool isRdOnly() const { return (m_oflags & 0x1) == 0x1; }
00077
00078 OParams& wrOnly() { m_oflags |= 0x2; return *this; }
00079 bool isWrOnly() const { return (m_oflags & 0x2) == 0x2; }
00080
00081 OParams& rdwr() { m_oflags |= 0x3; return *this; }
00082 bool isRdwr() const { return (m_oflags & 0x3) == 0x3; }
00083
00089 OParams& append() { m_oflags |= 0x4; return *this; }
00090 bool isAppend() const { return (m_oflags & 0x4) == 0x4; }
00091
00099 OParams& truncate() { m_oflags |= 0x8; return *this; }
00100 bool isTruncate() const { return (m_oflags & 0x8) == 0x8; }
00101
00102 OParams& shNoRead() { m_shflags |= 0x1; return *this; }
00103 bool isShNoRead() const { return (m_shflags & 0x1) == 0x1; }
00104
00105 OParams& shNoWrite() { m_shflags |= 0x2; return *this; }
00106 bool isShNoWrite() const { return (m_shflags & 0x2) == 0x2; }
00107
00108 OParams& shNone() { m_shflags |= 0x3; return *this; }
00109 bool isShNone() const { return (m_shflags & 0x3) == 0x3; }
00110 };
00111
00129 class CParams: public OParams
00130 {
00131 uint32 m_cflags;
00132 uint32 m_cmode;
00133 friend class VFSProvider;
00134
00135 public:
00136 CParams():
00137 m_cflags(0),
00138 m_cmode( 0644 )
00139 {}
00140
00148 CParams& noOvr() { m_cflags |= 0x1; return *this; }
00149 bool isNoOvr() const { return (m_cflags & 0x1) == 0x1; }
00150
00157 CParams& noStream() { m_cflags |= 0x2; return *this; }
00158 bool isNoStream() const { return (m_cflags & 0x2) == 0x2; }
00159
00160 CParams& createMode( uint32 cm ) { m_cmode = cm; return *this; }
00161 uint32 createMode() const { return m_cmode; }
00162 };
00163
00164 inline const String& protocol() const { return m_servedProto; }
00165
00169 inline Stream *open( const URI &uri ) {
00170 return open( uri, OParams() );
00171 }
00172
00174 virtual Stream* open( const URI &uri, const OParams &p )=0;
00175
00176 inline Stream* create( const URI &uri ) {
00177 bool dummy;
00178 return create( uri, CParams(), dummy );
00179 }
00180
00181 inline Stream* create( const URI& uri, bool &bSuccess ) {
00182 return create( uri, CParams(), bSuccess );
00183 }
00184
00185 inline Stream* create( const URI& uri, const CParams &p ) {
00186 bool dummy;
00187 return create( uri, p, dummy );
00188 }
00189
00190 virtual bool link( const URI &uri1, const URI &uri2, bool bSymbolic )=0;
00191 virtual bool unlink( const URI &uri )=0;
00192
00193 virtual Stream *create( const URI &uri, const CParams &p, bool &bSuccess )=0;
00194
00195 virtual DirEntry* openDir( const URI &uri )=0;
00196
00197 virtual bool mkdir( const URI &uri, uint32 mode )=0;
00198 virtual bool rmdir( const URI &uri )=0;
00199 virtual bool move( const URI &suri, const URI &duri )=0;
00200
00201 virtual bool readStats( const URI &uri, FileStat &s )=0;
00202 virtual bool writeStats( const URI &uri, const FileStat &s )=0;
00203
00204 virtual bool chown( const URI &uri, int uid, int gid )=0;
00205 virtual bool chmod( const URI &uri, int mode )=0;
00206
00215 virtual int64 getLastFsError()=0;
00216
00221 virtual Error *getLastError()=0;
00222 };
00223 }
00224
00225 #endif
00226
00227