vrfileman
diff src/fs.h @ 1:9e3d77dad51b
moving on...
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 31 Jan 2015 20:01:35 +0200 |
parents | |
children | 282da6123fd4 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/fs.h Sat Jan 31 20:01:35 2015 +0200 1.3 @@ -0,0 +1,65 @@ 1.4 +#ifndef FS_H_ 1.5 +#define FS_H_ 1.6 + 1.7 +#include <vector> 1.8 + 1.9 +class FSNode { 1.10 +protected: 1.11 + char *path, *name; 1.12 + FSNode *parent; 1.13 + 1.14 + std::vector<FSNode*> children; 1.15 + bool expanded; 1.16 + 1.17 + unsigned int uid, gid, mode; 1.18 + 1.19 +private: 1.20 + FSNode(const FSNode&); 1.21 + FSNode &operator =(const FSNode&); 1.22 + 1.23 +public: 1.24 + FSNode(); 1.25 + virtual ~FSNode(); 1.26 + 1.27 + void init(); 1.28 + void destroy(); 1.29 + void destroy_tree(); 1.30 + 1.31 + virtual void set_path(const char *path); 1.32 + virtual void set_name(const char *name); 1.33 + 1.34 + virtual const char *get_path() const; 1.35 + virtual const char *get_name() const; 1.36 + 1.37 + virtual void add_child(FSNode *node); 1.38 + 1.39 + virtual FSNode *get_parent(); 1.40 + virtual const FSNode *get_parent() const; 1.41 + 1.42 + virtual int get_child_count() const; 1.43 + virtual FSNode *get_child(int n); 1.44 + virtual const FSNode *get_child(int n) const; 1.45 + 1.46 + virtual void expand(); 1.47 + virtual bool is_expanded() const; 1.48 +}; 1.49 + 1.50 +class FSDir : public FSNode { 1.51 +public: 1.52 + FSDir(); 1.53 + 1.54 + virtual void expand(); 1.55 +}; 1.56 + 1.57 +class FSFile : public FSNode { 1.58 +protected: 1.59 + unsigned long size; 1.60 + 1.61 +public: 1.62 + FSFile(); 1.63 + 1.64 + void set_size(unsigned long s); 1.65 + unsigned long get_size() const; 1.66 +}; 1.67 + 1.68 +#endif // FS_H_