Make fs::tree_t member data private

This commit is contained in:
Allan Odgaard
2013-03-19 22:50:53 +01:00
parent 3ceefce2e4
commit 42cd2f93df
2 changed files with 13 additions and 7 deletions

View File

@@ -234,14 +234,14 @@ namespace fs
if(cwd == path)
{
fs::node_t newNode(cwd);
if(node._type != newNode._type || node._modified != newNode._modified)
if(node.type() != newNode.type() || node.modified() != newNode.modified())
{
if(node._type == fs::node_t::kNodeTypeMissing) _changes["created"].push_back(cwd);
else if(newNode._type == fs::node_t::kNodeTypeMissing) _changes["deleted"].push_back(cwd);
else _changes["changes"].push_back(cwd);
if(node.type() == fs::node_t::kNodeTypeMissing) _changes["created"].push_back(cwd);
else if(newNode.type() == fs::node_t::kNodeTypeMissing) _changes["deleted"].push_back(cwd);
else _changes["changes"].push_back(cwd);
if(node._type == newNode._type && node._type == fs::node_t::kNodeTypeDirectory)
node._entries.swap(newNode._entries);
if(node.type() == newNode.type() && node.type() == fs::node_t::kNodeTypeDirectory)
newNode.set_entries(node.entries());
node = newNode;
}
node.rescan(path::parent(cwd), _dir_glob, _file_glob, &_changes);

View File

@@ -23,12 +23,18 @@ namespace fs
node_type_t type () const { return _type; }
time_t modified () const { return _modified; }
nodes_ptr entries () const { return _entries; }
void set_entries (nodes_ptr newEntries) { _entries = newEntries; }
bool operator== (node_t const& rhs) const { return _name == rhs._name && _resolved == rhs._resolved && _type == rhs._type && _modified == rhs._modified && (!_entries && !rhs._entries || _entries && rhs._entries && *_entries == *rhs._entries); }
bool operator!= (node_t const& rhs) const { return !(*this == rhs); }
node_t (std::string const& name, std::string const& resolved, node_type_t type, time_t modified = 0, nodes_ptr const& entries = nodes_ptr()) : _name(name), _resolved(resolved), _type(type), _modified(modified), _entries(entries) { }
node_t& rescan (std::string const& cwd, path::glob_t const& dirGlob, path::glob_t const& fileGlob, std::map< std::string, std::vector<std::string> >* changes = NULL);
private:
node_t (std::string const& name, std::string const& resolved, node_type_t type, time_t modified = 0, nodes_ptr const& entries = nodes_ptr()) : _name(name), _resolved(resolved), _type(type), _modified(modified), _entries(entries) { }
friend plist::dictionary_t to_plist (node_t const& node);
friend node_t from_plist (plist::any_t const& plist);
std::string _name;
std::string _resolved;
node_type_t _type;