Exemple #1
0
FilesystemNode FilesystemNode::getChild(const String &name) const {
	if (_realNode == 0)
		return *this;

	assert(_realNode->isDirectory());
	AbstractFilesystemNode *node = _realNode->child(name);
	return FilesystemNode(node);
}
Exemple #2
0
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FilesystemNode FilesystemNode::getParent() const
{
  if (_realNode == 0)
    return *this;

  AbstractFilesystemNode* node = _realNode->getParent();
  if (node == 0)
    return *this;
  else
    return FilesystemNode(node);
}
Exemple #3
0
bool FilesystemNode::listDir(FSList &fslist, ListMode mode) const {
	if (!_realNode || !_realNode->isDirectory())
		return false;

	AbstractFSList tmp;
	
	if (!_realNode->listDir(tmp, mode))
		return false;
	
	fslist.clear();
	for (AbstractFSList::iterator i = tmp.begin(); i != tmp.end(); ++i) {
		fslist.push_back(FilesystemNode(*i));
	}
	
	return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string AbstractFilesystemNode::getAbsolutePath(const string& p,
                                               const string& startpath,
                                               const string& ext)
{
  // Does p start with the root directory or the given startpath?
  // If not, it isn't an absolute path
  string path = FilesystemNode(p).getPath(false);
  if(!BSPF_startsWithIgnoreCase(p, startpath+"/") &&
     !BSPF_startsWithIgnoreCase(p, "/"))
    path = startpath + "/" + p;

  // Does the path have a valid extension?
  // If not, we add the given one
  string::size_type idx = path.find_last_of('.');
  if(idx != string::npos)
  {
    if(!BSPF_equalsIgnoreCase(path.c_str() + idx + 1, ext))
      path = path.replace(idx+1, ext.length(), ext);
  }
  else
    path += "." + ext;

  return path;
}