vrfileman

diff 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 diff
     1.1 --- a/src/fs.h	Sat Jan 31 20:01:35 2015 +0200
     1.2 +++ b/src/fs.h	Sun Feb 01 12:51:10 2015 +0200
     1.3 @@ -4,26 +4,37 @@
     1.4  #include <vector>
     1.5  
     1.6  class FSNode {
     1.7 +public:
     1.8 +	enum Type { UNKNOWN, DIRECTORY, REGFILE, LINK, DEVICE, SOCKET, FIFO };
     1.9 +
    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 +	bool expanded, sorted;
    1.17  
    1.18 +	Type type;
    1.19  	unsigned int uid, gid, mode;
    1.20  
    1.21  private:
    1.22  	FSNode(const FSNode&);
    1.23  	FSNode &operator =(const FSNode&);
    1.24  
    1.25 +	void sort_children();
    1.26 +
    1.27  public:
    1.28  	FSNode();
    1.29  	virtual ~FSNode();
    1.30  
    1.31 -	void init();
    1.32 -	void destroy();
    1.33 -	void destroy_tree();
    1.34 +	virtual void init();
    1.35 +	virtual void destroy();
    1.36 +	virtual void destroy_tree();
    1.37 +
    1.38 +	virtual void set_type(Type type);
    1.39 +	virtual Type get_type() const;
    1.40 +	virtual bool is_file() const;
    1.41 +	virtual bool is_directory() const;
    1.42  
    1.43  	virtual void set_path(const char *path);
    1.44  	virtual void set_name(const char *name);
    1.45 @@ -31,7 +42,11 @@
    1.46  	virtual const char *get_path() const;
    1.47  	virtual const char *get_name() const;
    1.48  
    1.49 -	virtual void add_child(FSNode *node);
    1.50 +	virtual bool add_child(FSNode *node);
    1.51 +	virtual bool remove_child(FSNode *node);
    1.52 +
    1.53 +	virtual int find_child(FSNode *node) const;
    1.54 +	virtual int find_child(const char *name) const;
    1.55  
    1.56  	virtual FSNode *get_parent();
    1.57  	virtual const FSNode *get_parent() const;
    1.58 @@ -40,7 +55,7 @@
    1.59  	virtual FSNode *get_child(int n);
    1.60  	virtual const FSNode *get_child(int n) const;
    1.61  
    1.62 -	virtual void expand();
    1.63 +	virtual bool expand();
    1.64  	virtual bool is_expanded() const;
    1.65  };
    1.66  
    1.67 @@ -48,18 +63,19 @@
    1.68  public:
    1.69  	FSDir();
    1.70  
    1.71 -	virtual void expand();
    1.72 +	virtual bool expand();
    1.73  };
    1.74  
    1.75  class FSFile : public FSNode {
    1.76  protected:
    1.77  	unsigned long size;
    1.78 +	enum Type type;
    1.79  
    1.80  public:
    1.81  	FSFile();
    1.82  
    1.83 -	void set_size(unsigned long s);
    1.84 -	unsigned long get_size() const;
    1.85 +	virtual void set_size(unsigned long s);
    1.86 +	virtual unsigned long get_size() const;
    1.87  };
    1.88  
    1.89  #endif	// FS_H_