1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
/*
* HT Editor
* vfs.h
*
* Copyright (C) 1999-2002 Stefan Weyergraf
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __VFS_H__
#define __VFS_H__
#include "htobj.h"
#include "htreg.h"
#include "stream.h"
#define VFS_DIR_MAX 256
#define VFS_PROTO_MAX 16
#define VFS_URL_MAX (VFS_DIR_MAX+VFS_PROTO_MAX+1)
/*
* class RegNodeFile
*/
class RegNodeFile: public MemoryFile {
protected:
char *nodename;
uint access_mode0;
uint open_mode;
/* overwritten */
int load_node(ObjectStream &s, ht_registry_node **node);
void store_node(ObjectStream &s, ht_registry_node *node);
public:
RegNodeFile(const char *nodename, uint am, uint om);
virtual ~RegNodeFile();
};
/*
* class Vfs
*/
#define VFSCAP_WRITABLE 1
class Vfs: public Object {
public:
/* new */
virtual int canonicalize(char *result, const char *filename, const char *cwd) = 0;
virtual int createFile(const char *filename, uint createtype) = 0;
virtual int deleteFile(const char *filename) = 0;
virtual void * enumFiletype(uint *type, char **name, void *handle) = 0;
virtual int compareFilenames(const char *a, const char *b) = 0;
virtual bool findFirst(const char *dirname, pfind_t *f) = 0;
virtual bool findNext(pfind_t *f) = 0;
virtual bool findClose(pfind_t *f) = 0;
virtual int getCaps() = 0;
virtual const char * getProtoName() = 0;
virtual is_path_delim isPathDelim() = 0;
virtual int makeDir(const char *dirname) = 0;
virtual int open(const char *filename, bool edit) = 0;
virtual int pstat(pstat_t *s, const char *filename) = 0;
virtual int renameFile(const char *filename, const char *newname) = 0;
virtual int fileClose(File *f) = 0;
virtual int fileOpen(const char *filename, IOAccessMode access_mode, FileOpenMode open_mode, File **f) = 0;
};
/*
* class LocalFs
*/
class LocalFs: public Vfs {
public:
void init();
virtual void done();
/* overwritten */
virtual int canonicalize(char *result, const char *filename, const char *cwd);
virtual int compareFilenames(const char *a, const char *b);
virtual int createFile(const char *filename, uint createtype);
virtual int deleteFile(const char *filename);
virtual void * enumFiletype(uint *type, char **name, void *handle);
virtual bool findFirst(const char *dirname, pfind_t *f);
virtual bool findNext(pfind_t *f);
virtual bool findClose(pfind_t *f);
virtual int getCaps();
virtual const char * getProtoName();
virtual is_path_delim isPathDelim();
virtual int makeDir(const char *dirname);
virtual int open(const char *filename, bool edit);
virtual int pstat(pstat_t *s, const char *filename);
virtual int renameFile(const char *filename, const char *newname);
virtual int fileClose(File *f);
virtual int fileOpen(const char *filename, IOAccessMode access_mode, FileOpenMode open_mode, File **f);
};
/*
* class RegistryFs
*/
class RegistryFs: public Vfs {
protected:
ht_registry_node *enum_last;
char *enum_dir;
/* new */
void create_pfind_t(pfind_t *f, const ht_registry_node *node);
void create_pstat_t(pstat_t *s, ht_registry_data *data, ht_registry_node_type type);
public:
void init();
virtual void done();
/* overwritten */
virtual int canonicalize(char *result, const char *filename, const char *cwd);
virtual int createFile(const char *filename, uint createtype);
virtual int deleteFile(const char *filename);
virtual void * enumFiletype(uint *type, char **name, void *handle);
virtual int compareFilenames(const char *a, const char *b);
virtual bool findFirst(const char *dirname, pfind_t *f);
virtual bool findNext(pfind_t *f);
virtual bool findClose(pfind_t *f);
virtual int getCaps();
virtual const char * getProtoName();
virtual is_path_delim isPathDelim();
virtual int makeDir(const char *dirname);
virtual int open(const char *filename, bool edit);
virtual int pstat(pstat_t *s, const char *filename);
virtual int renameFile(const char *filename, const char *newname);
virtual int fileClose(File *f);
virtual int fileOpen(const char *filename, IOAccessMode access_mode, FileOpenMode open_mode, File **f);
};
#endif /* __VFS_H__ */
|