void Parser::destroy(const std::list<string>& names) { DirectoryPrx dir = _dirs.front(); for(std::list<string>::const_iterator i = names.begin(); i != names.end(); ++i) { if(*i == "*") { NodeDescSeq nodes = dir->list(); for(NodeDescSeq::iterator j = nodes.begin(); j != nodes.end(); ++j) { try { j->proxy->destroy(); } catch(const PermissionDenied& ex) { cout << "cannot remove `" << j->name << "': " << ex.reason << endl; } } return; } else { NodeDesc d; try { d = dir->find(*i); } catch(const NoSuchName&) { cout << "`" << *i << "': no such file or directory" << endl; return; } try { d.proxy->destroy(); } catch(const PermissionDenied& ex) { cout << "cannot remove `" << *i << "': " << ex.reason << endl; } } } }
Filesystem::NodeDescSeq Filesystem::DirectoryI::list(const Ice::Current& c) { IceUtil::Mutex::Lock lock(_mutex); if(_destroyed) { throw Ice::ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation); } NodeDict::const_iterator p; NodeDescSeq result; for(p = nodes.begin(); p != nodes.end(); ++p) { result.push_back(p->second); } return result; }
NodeDescSeq FilesystemI::DirectoryI::list(const Current& c) { IceUtil::Mutex::Lock lock(_m); if(_destroyed) { throw ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation); } NodeDescSeq ret; for(Contents::const_iterator i = _contents.begin(); i != _contents.end(); ++i) { NodeDesc d; d.name = i->first; d.type = FilePtr::dynamicCast(i->second) ? FileType : DirType; d.proxy = NodePrx::uncheckedCast(c.adapter->createProxy(i->second->id())); ret.push_back(d); } return ret; }
void Parser::list(const DirectoryPrx& dir, bool recursive, int depth) { string indent(depth++, '\t'); NodeDescSeq contents = dir->list(); for(NodeDescSeq::const_iterator i = contents.begin(); i != contents.end(); ++i) { DirectoryPrx d = i->type == DirType ? DirectoryPrx::uncheckedCast(i->proxy) : (DirectoryPrx)0; cout << indent << i->name << (d ? " (directory)" : " (file)"); if(d && recursive) { cout << ":" << endl; list(d, true, depth); } else { cout << endl; } } }