Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

vfs.h

Go to the documentation of this file.
00001 /*
00002  *      HT Editor
00003  *      vfs.h
00004  *
00005  *      Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de)
00006  *
00007  *      This program is free software; you can redistribute it and/or modify
00008  *      it under the terms of the GNU General Public License version 2 as
00009  *      published by the Free Software Foundation.
00010  *
00011  *      This program is distributed in the hope that it will be useful,
00012  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *      GNU General Public License for more details.
00015  *
00016  *      You should have received a copy of the GNU General Public License
00017  *      along with this program; if not, write to the Free Software
00018  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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  *      class RegNodeFile
00034  */
00035 
00036 class RegNodeFile: public ht_mem_file {
00037 protected:
00038         char *nodename;
00039         UINT access_mode0;
00040         UINT open_mode;
00041 
00042 /* overwritten */
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 /* overwritten */
00049         virtual bool            set_access_mode(UINT access_mode);
00050 };
00051 
00052 /*
00053  *   class Vfs
00054  */
00055 
00056 #define VFSCAP_WRITABLE         1
00057 
00058 class Vfs: public Object {
00059 public:
00060 /* new */
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  *      class LocalFs
00082  */
00083 
00084 class LocalFs: public Vfs {
00085 public:
00086                         void            init();
00087         virtual void            done();
00088 /* overwritten */
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  *      class RegistryFs
00110  */
00111 
00112 class RegistryFs: public Vfs {
00113 protected:
00114         char *enum_last;
00115         char *enum_dir;
00116 
00117 /* new */
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 /* overwritten */
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 /* __VFS_H__ */
00144 

Generated on Fri May 7 21:15:45 2004 by doxygen 1.3.5