Example #1
0
bool nglZipFS::GetChildren(const nglPath& rPath, std::list<nglPath>& rChildren)
{
  nglString p(rPath.GetVolumeLessPath());
  p.TrimLeft(_T('/'));
  //wprintf(_T("trimed path '%s'\n"), p.GetChars());
  nglPath path(p);
  Node* pNode = mRoot.Find(path);
  if (!pNode)
    return 0;

  std::list<nglZipFS::Node*>::iterator it;
  std::list<nglZipFS::Node*>::iterator end = pNode->mpChildren.end();
  for (it = pNode->mpChildren.begin(); it != end; ++it)
  {
    if (*it)
    {
      nglZipPath path(this, rPath.GetPathName().IsEmpty()? (*it)->mName : rPath.GetPathName() );
      if (!rPath.GetPathName().IsEmpty())
        path += nglPath((*it)->mName);

      rChildren.push_back(path);
    }
  }
  return rChildren.size();
}
bool nuiNativeResourceVolume::GetPathInfo(const nglPath& rPath, nglPathInfo& rInfo)
{
	nglString tmp = rPath.GetVolumeLessPath();
  nglPath path(tmp);
	tmp.TrimLeft(L'/');
	nglPath trimmed(tmp);
  
  if (!path.GetPathName().Compare(_T("/")))
  {
    // we act like this is a folder
    rInfo.Exists = true;      ///< Node existence. All other fields are invalid if set to false.
    rInfo.IsLeaf = false;      ///< Leaf (file or assimilable) or non-leaf (folder)
    rInfo.CanRead = true;     ///< True if the file (leaf) can be read or the folder (non-leaf) can be traversed and its content listed
    rInfo.CanWrite = false;    ///< True if the file (leaf) can be written to or a new node can be created in this folder (non-leaf)
    rInfo.LastAccess = 0;  ///< nglTime stamp of last access (read or exec)
    rInfo.LastMod = 0;     ///< nglTime stamp of last modification (write)
    rInfo.Size = 0;      ///< If the node is a leaf, size in bytes. If non-leaf, always zero.
    rInfo.Visible = true; ///< Always visible...
    
    return true;  
  }

  std::map<nglPath, std::set<nglString> >::const_iterator it = mItems.find(trimmed);
	
  if (it != mItems.end())
  {
    // This is a folder
    rInfo.Exists = true;      ///< Node existence. All other fields are invalid if set to false.
    rInfo.IsLeaf = false;      ///< Leaf (file or assimilable) or non-leaf (folder)
    rInfo.CanRead = true;     ///< True if the file (leaf) can be read or the folder (non-leaf) can be traversed and its content listed
    rInfo.CanWrite = false;    ///< True if the file (leaf) can be written to or a new node can be created in this folder (non-leaf)
    rInfo.LastAccess = 0;  ///< nglTime stamp of last access (read or exec)
    rInfo.LastMod = 0;     ///< nglTime stamp of last modification (write)
    rInfo.Size = 0;      ///< If the node is a leaf, size in bytes. If non-leaf, always zero.
    rInfo.Visible = true; ///< Always visible...
    
    return true;
  }
  
  nuiNativeResource* pRes = new nuiNativeResource(path);
  if (pRes && pRes->IsValid())
  {
    // This is a file
    rInfo.Exists = true;      ///< Node existence. All other fields are invalid if set to false.
    rInfo.IsLeaf = true;      ///< Leaf (file or assimilable) or non-leaf (folder)
    rInfo.CanRead = true;     ///< True if the file (leaf) can be read or the folder (non-leaf) can be traversed and its content listed
    rInfo.CanWrite = false;    ///< True if the file (leaf) can be written to or a new node can be created in this folder (non-leaf)
    rInfo.LastAccess = 0;  ///< nglTime stamp of last access (read or exec)
    rInfo.LastMod = 0;     ///< nglTime stamp of last modification (write)
    rInfo.Size = pRes->Available();      ///< If the node is a leaf, size in bytes. If non-leaf, always zero.
    rInfo.Visible = true; ///< Always visible...
    
    delete pRes;
    return true;
  }
  
  delete pRes;
  
  return false;
}
bool nuiNativeResourceVolume::GetChildren(const nglPath& rPath, std::list<nglPath>& rChildren)
{
  nglString p(rPath.GetVolumeLessPath());
  p.TrimLeft(_T('/'));
  //wprintf(_T("trimed path '%ls'\n"), p.GetChars());
  nglPath path(p);
  //wprintf(_T("GetChildren(\"%ls\") [%ls] [%ls]\n"), rPath.GetChars(), path.GetChars(), p.GetChars());
  
  std::map<nglPath, std::set<nglString> >::const_iterator fit = mItems.find(path);
  
  if (fit == mItems.end())
  {
    // The path has to point to a folder, not a file
    return false;
  }
  
  const std::set<nglString>& rChildrenSet(fit->second);
  std::set<nglString>::const_iterator it = rChildrenSet.begin();
  std::set<nglString>::const_iterator end = rChildrenSet.end();
  
  while (it != end)
  {
    nglPath p(rPath);
    p += *it;
    rChildren.push_back(p);
    
    ++it;
  }
  return true;
}
Example #4
0
bool nglZipFS::GetPathInfo(const nglPath& rPath, nglPathInfo& rInfo)
{
  nglString p(rPath.GetVolumeLessPath());
  p.TrimLeft(_T('/'));
  //wprintf(_T("trimed path '%s'\n"), p.GetChars());
  nglPath path(p);

  Node* pChild = mRoot.Find(path); 

  rInfo.Exists = pChild != NULL;
  rInfo.CanRead = rInfo.Exists;
  rInfo.CanWrite = false;
  rInfo.IsLeaf = (pChild != NULL) ? (pChild->mIsLeaf) : false;
  rInfo.Size = (pChild != NULL) ? (pChild->mSize) : 0;
  rInfo.Visible = true; ///< Always visible...

  return pChild != NULL;
}