00001
00017 #ifndef _MFS_H_
00018 #define _MFS_H_
00019
00020 #include "LgiDefs.h"
00021 #include "GMem.h"
00022 #include "GFile.h"
00023 #include "GContainers.h"
00024 #include "GVariant.h"
00025 #include "GSemaphore.h"
00026 #include "GString.h"
00027 #include "GArray.h"
00028
00030 class MFileSystem;
00031 class MFileQuery;
00032 class MMetaData;
00033 class MFile;
00034
00036 class MFileSystem
00037 {
00038 friend class MFileQuery;
00039 friend class MMetaData;
00040 friend class MFile;
00041 friend class MTreeNode;
00042
00043 class MFileSystemPrivate *d;
00044
00045 public:
00047 MFileSystem(char *File = 0);
00049 virtual ~MFileSystem();
00050
00051
00052
00054 bool CreateNewSystem(char *File);
00056 bool OpenSystem(char *File);
00058 bool CloseSystem();
00060 char *GetCurrentFile();
00062 bool Commit();
00063
00064
00065
00067 bool CreateFolder(char *Path);
00069 bool DeleteFolder(char *Path);
00070
00071
00072
00074 bool DeleteFile(char *File);
00076 bool MoveFile(char *To, char *From, int64 *Progress = 0);
00078 bool CopyFile(char *To, char *From, int64 *Progress = 0);
00079 };
00080
00082 class MFileQuery
00083 {
00084 class MFileQueryPrivate *d;
00085
00086 public:
00087 MFileQuery(MFileSystem *sys, char *query = 0);
00088 virtual ~MFileQuery();
00089
00091 bool SetQuery(char *query);
00093 char *GetQuery();
00094
00097 virtual void OnResults
00098 (
00100 List<char> &NewPaths,
00102 List<char> &DelPaths
00103 ) {}
00104 };
00105
00107 class MMetaData : public GVariant
00108 {
00109 MFile *File;
00110 char *Name;
00111 bool Ro;
00112
00113 public:
00114 MMetaData(MFile *file, char *name);
00115 ~MMetaData();
00116
00118 char *GetName();
00120 bool IsReadOnly();
00124 bool Commit();
00125 };
00126
00128 class MFile : public GFile
00129 {
00130 class MFilePrivate *d;
00131
00132 public:
00133 MFile(MFileSystem *sys, char *Path = 0, int Mode = O_READ);
00134 ~MFile();
00135
00136
00137
00138 int Open(char *Name, int Attrib);
00139 bool IsOpen();
00140 int Close();
00141 int GetOpenMode();
00142 int64 GetPos();
00143 int64 SetPos(int64 Pos);
00144 int64 GetSize();
00145 int64 SetSize(int64 Size);
00146 int Read(void *Buffer, int Size, int Flags = 0);
00147 int Write(void *Buffer, int Size, int Flags = 0);
00148 char *GetName();
00149 int64 Seek(int64 To, int Whence);
00150 bool Eof();
00151 void SetStatus(bool s = false);
00152 bool GetStatus();
00153 void SetSwap(bool s);
00154 bool GetSwap();
00155
00157
00159 MMetaData *FirstMd();
00161 MMetaData *NextMd();
00163 MMetaData *AddMd();
00165 bool DelMd(char *Name);
00166 };
00167
00168 #endif