/* * ventry.h * Copyright (C) 2004 Luca Ferroni <fferroni@cs.unibo.it> * * This class manages virtual entries: * a virtual entry is a node of the virtual tree * this is the base class to store virtual file system nodes * and their relationship. * * This file is released under the GPL v2. * * This file may be redistributed under the terms of the GNU Public * License. */ #ifndef _VENTRY_H #define _VENTRY_H #include <string> #include <sys/types.h> #include <sys/stat.h> #include <lufs/proto.h> #include "list.h" using namespace std; class Ventry { public: ~Ventry(); Ventry( string fname, struct lufs_fattr *fattr = 0, char *flink = 0, void *priv = 0); Ventry *clone() const; //! Inline access to private values string getName() const { return name; } string getParentName() const { return parentName; } string getLink() const { return link; } struct lufs_fattr getAttr() const { return attr; } bool isDir() const { return (S_ISDIR(this->attr.f_mode)); } //! Set the private attributes void setAttr(struct lufs_fattr *fattr); //! Operations on lists void addChild(Ventry *ve); void delChildren(unsigned int &entries); Ventry *searchChild(string) const; Ventry *search(string fname) const; void readdir(struct directory*) const; //! save its data to disk int saveToDisk(ofstream &); //! load its data from disk bool loadFromDisk(ifstream &, unsigned int &); private: //! Ventries relationship: //! Brothers are the ventries at the same level //!Children are the ventries deeper in the directory tree struct list_head brothers; struct list_head children; //! Ventry details string name; string parentName; string link; struct lufs_fattr attr; time_t stamp; //void *priv; protected: //! Private useful methods string parentDir(string path); }; #endif