19 #include<boost/tokenizer.hpp>
20 #include <boost/thread/thread.hpp>
21 using namespace boost;
36 LOG(
DEBUG) <<
"WsFileSystemTree::~WsFileSystemTree() : deleting ";
43 LOG(
INFO) <<
"WsFileSystemTree::start() : Building FsTree for path " <<
m_p;
47 LOG(
ERROR) <<
"WsFileSystemTree::start() : Error while building FsTree for path " <<
m_p;
49 LOG(
INFO) <<
"WsFileSystemTree::start() : FsTree built with success for path " <<
m_p;
61 n.get()->setProperties(props);
63 std::time_t t = boost::filesystem::last_write_time( filePath ) ;
64 n.get()->setModifyDate(t);
65 n.get()->setSize(boost::filesystem::file_size(filePath));
97 std::time_t t = boost::filesystem::last_write_time( dirPath ) ;
98 n.get()->setModifyDate(t);
99 dynamic_cast<WsDirNode*
>(n.get())->setResources(resources);
103 props.get()->createPropertiesDirectories();
104 n.get()->setProperties(props);
128 if (
m_current.get() != 0 && parent.get() != 0 && is_directory(p)) {
138 LOG(
ERROR) <<
"WsFileSystemTree::getRoot() : FileSystemTree not loaded" << endl;
147 LOG(
ERROR) <<
"WsFileSystemTree::eatPath() : FileSystemTree not loaded" << endl;
150 typedef tokenizer<char_separator<char> >
152 char_separator<char> sep(
"/");
153 tokenizer tok(p, sep);
155 for (tokenizer::iterator beg = tok.begin(); beg != tok.end(); ++beg) {
156 NodePtr res = curNode.get()->getNodeByName(*beg);
171 path p = newNode.get()->getPath();
173 if (parent.get() == 0)
176 if ( !parent.get()->isDirectory() )
178 if ( newNode.get()->isRegularFile()) {
187 LOG(
DEBUG) <<
"WsFileSystemTree::insertNode() : Node " << p.string() <<
" inserted in FileSystemTree";
238 gettimeofday(&time, 0);
239 long millis = (time.tv_sec * 1000) + (time.tv_usec / 1000);
240 m_stamp = boost::lexical_cast<
string>(millis);
const std::string & getStamp()
returns the Tree unique stamp
Abstract class used to crawl a directory.
boost::shared_ptr< WsAbstractNode > NodePtr
WsFileSystemTree(const std::string &p, bool m=false)
Constructor for the FileSystemTree object.
std::vector< boost::filesystem::path > m_monitorPaths
int start()
crawls the diretory and sorts the children. It is called by WsDirectoryCrawler::start() ...
NodePtr getRoot()
returns the root of the WsFileSystemTree
int start()
Start crawling over all the files and directories/subdirectories.
Reprensents a Directory on disk.
Reprensents a File on disk.
NodePtr eatPath(const std::string &p)
void endChild(const boost::filesystem::path &p)
this method is called when finished browsing the subdir
const boost::filesystem::path & getRootPath() const
returns the boost::filesystem::path to the base directory where documents are stored ...
int getUseCount()
returns the number of users that are using this fileSystemTree version
int applyDirectory(const boost::filesystem::path &dirPath)
this method is called by browse when the boost::filesystem::path is a folder
void incrementUseCount()
increments the number of uses of the tree by 1
int applyFile(const boost::filesystem::path &filePath)
this method is called by browse when the boost::filesystem::path is a file
boost::filesystem::path m_rootPath
int createResourcesDirectories()
boost::shared_ptr< WsNodeProperties > NodePropertiesPtr
Structure representing all the fs tree from the root.
int insertNode(NodePtr newNode)
inserts the node in the tree The node is inserted on the right place on the tree depending on it's pa...
std::vector< boost::filesystem::path > & getMonitorPaths()
returns the std::vector containing the boost::filesystem::path that should be monitored by the WsUpda...
void decrementUseCount()
decrements the numbers of uses by one
void createStamp()
creates unique stamp for the tree
void beginChild(const boost::filesystem::path &p)
this method is called before browsing a subdirectory