vrfileman

view src/fs.h @ 5:d487181ee1d9

fixed movement
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 03 Feb 2015 03:35:14 +0200
parents 282da6123fd4
children b041bc1c38ad
line source
1 #ifndef FS_H_
2 #define FS_H_
4 #include <vector>
6 class FSNode {
7 public:
8 enum Type { UNKNOWN, DIRECTORY, REGFILE, LINK, DEVICE, SOCKET, FIFO };
10 protected:
11 char *path, *name;
12 FSNode *parent;
14 std::vector<FSNode*> children;
15 bool expanded, sorted;
17 Type type;
18 unsigned int uid, gid, mode;
20 void *data;
22 private:
23 FSNode(const FSNode&);
24 FSNode &operator =(const FSNode&);
26 void sort_children();
28 public:
29 FSNode();
30 virtual ~FSNode();
32 virtual void init();
33 virtual void destroy();
34 virtual void destroy_tree();
36 virtual void set_type(Type type);
37 virtual Type get_type() const;
38 virtual bool is_file() const;
39 virtual bool is_directory() const;
41 virtual void set_path(const char *path);
42 virtual void set_name(const char *name);
44 virtual const char *get_path() const;
45 virtual const char *get_name() const;
47 virtual bool add_child(FSNode *node);
48 virtual bool remove_child(FSNode *node);
50 virtual int find_child(FSNode *node) const;
51 virtual int find_child(const char *name) const;
53 virtual FSNode *get_parent();
54 virtual const FSNode *get_parent() const;
56 virtual int get_child_count() const;
57 virtual FSNode *get_child(int n);
58 virtual const FSNode *get_child(int n) const;
60 virtual bool expand();
61 virtual bool is_expanded() const;
63 virtual void set_ext_data(void *data);
64 virtual void *get_ext_data() const;
65 };
67 class FSDir : public FSNode {
68 public:
69 FSDir();
71 virtual bool expand();
72 };
74 class FSFile : public FSNode {
75 protected:
76 unsigned long size;
77 enum Type type;
79 public:
80 FSFile();
82 virtual void set_size(unsigned long s);
83 virtual unsigned long get_size() const;
84 };
86 #endif // FS_H_