示例#1
0
util::Error RemoveDirectory(const acl::User& user, const VirtualPath& path)
{
  util::Error e(PP::DirAllowed<PP::Delete>(user, path));
  if (!e) return e;
  
  try
  {
    util::path::DirContainer dirCont(MakeReal(path).ToString());
    for (auto& name : dirCont)
    {
      if (name[0] !=  '.') return util::Error::Failure(ENOTEMPTY);
        
      util::path::Status status((MakeReal(path) / name).ToString());
      if (status.IsDirectory() || !status.IsWriteable())
        return util::Error::Failure(ENOTEMPTY);
    }
    
    
    for (auto& name : dirCont)
    {
      RealPath entryPath(MakeReal(path) / name);
      if (unlink(entryPath.CString()) < 0)
        return util::Error::Failure(errno);
    }
  }
  catch (const util::SystemError& e)
  {
    return util::Error::Failure(e.Errno());
  }
    
  return RemoveDirectory(MakeReal(path));
}
示例#2
0
util::Error CreateDirectory(const acl::User& user, const VirtualPath& path)
{
  util::Error e(PP::DirAllowed<PP::Makedir>(user, path));
  if (!e) return e;

  e = CreateDirectory(MakeReal(path));  
  if (e) SetOwner(MakeReal(path), Owner(user.ID(), user.PrimaryGID()));
  return e;
}
示例#3
0
void DirEnumerator::Readdir(const acl::User& user, const fs::VirtualPath& path, bool loadOwners)
{
  this->user  = &user;
  this->path = MakeReal(path);
  this->loadOwners = loadOwners;
  Readdir();
}
示例#4
0
DirEnumerator::DirEnumerator(const acl::User& user, const fs::VirtualPath& path, bool loadOwners) :
  user(&user),
  path(MakeReal(path)),
  totalBytes(0),
  loadOwners(loadOwners)
{
  Readdir();
}
示例#5
0
inline void
MakeReal( DistMatrix<T,U,V>& A )
{
#ifndef RELEASE
    PushCallStack("MakeReal");
#endif
    MakeReal( A.LocalMatrix() );
#ifndef RELEASE
    PopCallStack();
#endif
}
示例#6
0
util::Error ChangeDirectory(const acl::User& user, const VirtualPath& path)
{
  util::Error e(PP::DirAllowed<PP::View>(user, path));
  if (!e) return e;

  try
  {
    util::path::Status stat(MakeReal(path).ToString());
    if (!stat.IsDirectory()) return util::Error::Failure(ENOTDIR);
    if (!stat.IsExecutable()) return util::Error::Failure(EACCES);
  }
  catch (const util::SystemError& e)
  {
    return util::Error::Failure(e.Errno());
  }
  
  SetWorkDirectory(path);
  return util::Error::Success();
}
示例#7
0
util::Error RemoveDirectory(const RealPath& path)
{
  if (rmdir(MakeReal(path).CString()) < 0) return util::Error::Failure(errno);
  return util::Error::Success();
}
示例#8
0
util::Error CreateDirectory(const RealPath& path)
{
  if (mkdir(MakeReal(path).CString(), 0777) < 0) return util::Error::Failure(errno);
  return util::Error::Success();
}