00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __VFS_H__
00022 #define __VFS_H__
00023
00024 #include "htobj.h"
00025 #include "htreg.h"
00026 #include "stream.h"
00027
00028 #define VFS_DIR_MAX 256
00029 #define VFS_PROTO_MAX 16
00030 #define VFS_URL_MAX (VFS_DIR_MAX+VFS_PROTO_MAX+1)
00031
00032
00033
00034
00035
00036 class RegNodeFile: public ht_mem_file {
00037 protected:
00038 char *nodename;
00039 UINT access_mode0;
00040 UINT open_mode;
00041
00042
00043 int load_node(ht_object_stream *s, ht_registry_node_type *type, ht_registry_data **data);
00044 void store_node(ht_object_stream *s, ht_registry_node_type type, ht_registry_data *data);
00045 public:
00046 void init(const char *nodename, UINT am, UINT om);
00047 virtual void done();
00048
00049 virtual bool set_access_mode(UINT access_mode);
00050 };
00051
00052
00053
00054
00055
00056 #define VFSCAP_WRITABLE 1
00057
00058 class Vfs: public Object {
00059 public:
00060
00061 virtual int canonicalize(char *result, const char *filename, const char *cwd) = 0;
00062 virtual int createFile(const char *filename, UINT createtype) = 0;
00063 virtual int deleteFile(const char *filename) = 0;
00064 virtual void * enumFiletype(UINT *type, char **name, void *handle) = 0;
00065 virtual int compareFilenames(const char *a, const char *b) = 0;
00066 virtual bool findFirst(const char *dirname, pfind_t *f) = 0;
00067 virtual bool findNext(pfind_t *f) = 0;
00068 virtual bool findClose(pfind_t *f) = 0;
00069 virtual int getCaps() = 0;
00070 virtual const char * getProtoName() = 0;
00071 virtual is_path_delim isPathDelim() = 0;
00072 virtual int makeDir(const char *dirname) = 0;
00073 virtual int open(const char *filename, bool edit) = 0;
00074 virtual int pstat(pstat_t *s, const char *filename) = 0;
00075 virtual int renameFile(const char *filename, const char *newname) = 0;
00076 virtual int fileClose(ht_streamfile *f) = 0;
00077 virtual int fileOpen(const char *filename, UINT access_mode, UINT open_mode, ht_streamfile **f) = 0;
00078 };
00079
00080
00081
00082
00083
00084 class LocalFs: public Vfs {
00085 public:
00086 void init();
00087 virtual void done();
00088
00089 virtual int canonicalize(char *result, const char *filename, const char *cwd);
00090 virtual int compareFilenames(const char *a, const char *b);
00091 virtual int createFile(const char *filename, UINT createtype);
00092 virtual int deleteFile(const char *filename);
00093 virtual void * enumFiletype(UINT *type, char **name, void *handle);
00094 virtual bool findFirst(const char *dirname, pfind_t *f);
00095 virtual bool findNext(pfind_t *f);
00096 virtual bool findClose(pfind_t *f);
00097 virtual int getCaps();
00098 virtual const char * getProtoName();
00099 virtual is_path_delim isPathDelim();
00100 virtual int makeDir(const char *dirname);
00101 virtual int open(const char *filename, bool edit);
00102 virtual int pstat(pstat_t *s, const char *filename);
00103 virtual int renameFile(const char *filename, const char *newname);
00104 virtual int fileClose(ht_streamfile *f);
00105 virtual int fileOpen(const char *filename, UINT access_mode, UINT open_mode, ht_streamfile **f);
00106 };
00107
00108
00109
00110
00111
00112 class RegistryFs: public Vfs {
00113 protected:
00114 char *enum_last;
00115 char *enum_dir;
00116
00117
00118 void create_pfind_t(pfind_t *f, const char *key, ht_registry_data *data, ht_registry_node_type type);
00119 void create_pstat_t(pstat_t *s, ht_registry_data *data, ht_registry_node_type type);
00120 public:
00121 void init();
00122 virtual void done();
00123
00124 virtual int canonicalize(char *result, const char *filename, const char *cwd);
00125 virtual int createFile(const char *filename, UINT createtype);
00126 virtual int deleteFile(const char *filename);
00127 virtual void * enumFiletype(UINT *type, char **name, void *handle);
00128 virtual int compareFilenames(const char *a, const char *b);
00129 virtual bool findFirst(const char *dirname, pfind_t *f);
00130 virtual bool findNext(pfind_t *f);
00131 virtual bool findClose(pfind_t *f);
00132 virtual int getCaps();
00133 virtual const char * getProtoName();
00134 virtual is_path_delim isPathDelim();
00135 virtual int makeDir(const char *dirname);
00136 virtual int open(const char *filename, bool edit);
00137 virtual int pstat(pstat_t *s, const char *filename);
00138 virtual int renameFile(const char *filename, const char *newname);
00139 virtual int fileClose(ht_streamfile *f);
00140 virtual int fileOpen(const char *filename, UINT access_mode, UINT open_mode, ht_streamfile **f);
00141 };
00142
00143 #endif
00144