vrfileman

view src/fs.h @ 2:282da6123fd4

lalalala
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 01 Feb 2015 12:51:10 +0200
parents 9e3d77dad51b
children d487181ee1d9
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 private:
21 FSNode(const FSNode&);
22 FSNode &operator =(const FSNode&);
24 void sort_children();
26 public:
27 FSNode();
28 virtual ~FSNode();
30 virtual void init();
31 virtual void destroy();
32 virtual void destroy_tree();
34 virtual void set_type(Type type);
35 virtual Type get_type() const;
36 virtual bool is_file() const;
37 virtual bool is_directory() const;
39 virtual void set_path(const char *path);
40 virtual void set_name(const char *name);
42 virtual const char *get_path() const;
43 virtual const char *get_name() const;
45 virtual bool add_child(FSNode *node);
46 virtual bool remove_child(FSNode *node);
48 virtual int find_child(FSNode *node) const;
49 virtual int find_child(const char *name) const;
51 virtual FSNode *get_parent();
52 virtual const FSNode *get_parent() const;
54 virtual int get_child_count() const;
55 virtual FSNode *get_child(int n);
56 virtual const FSNode *get_child(int n) const;
58 virtual bool expand();
59 virtual bool is_expanded() const;
60 };
62 class FSDir : public FSNode {
63 public:
64 FSDir();
66 virtual bool expand();
67 };
69 class FSFile : public FSNode {
70 protected:
71 unsigned long size;
72 enum Type type;
74 public:
75 FSFile();
77 virtual void set_size(unsigned long s);
78 virtual unsigned long get_size() const;
79 };
81 #endif // FS_H_