Ejemplo n.º 1
0
bool MountSystem::rename(const Path& from,const Path& to)
{
   // Will only rename files on the same filesystem
   Path pa = _normalize(from);
   Path pb = _normalize(to);
   FileSystemRef fsa = _getFileSystemFromList(pa);
   FileSystemRef fsb = _getFileSystemFromList(pb);
   if (!fsa || !fsb)
      return false;
   if (fsa.getPointer() != fsb.getPointer())
   {
      _log(String::ToString("Cannot rename path %s to a different filesystem", from.getFullPath().c_str()));
      return false;
   }
   if (fsa->isReadOnly() || fsb->isReadOnly())
   {
      _log(String::ToString("Cannot rename path %s; source or target filesystem is read-only", from.getFullPath().c_str()));
      return false;
   }

   return fsa->rename(pa,pb);
}
Ejemplo n.º 2
0
bool MountSystem::remove(const Path& path)
{
   Path np = _normalize(path);
   FileSystemRef fs = _getFileSystemFromList(np);
   if (fs && fs->isReadOnly())
   {
      _log(String::ToString("Cannot remove path %s, filesystem is read-only", path.getFullPath().c_str()));
      return false;
   }
   if (fs != NULL)
      return fs->remove(np);
   return false;
}
Ejemplo n.º 3
0
FileRef MountSystem::createFile(const Path& path)
{
   Path np = _normalize(path);
   FileSystemRef fs = _getFileSystemFromList(np);

   if (fs && fs->isReadOnly())
   {
      _log(String::ToString("Cannot create file %s, filesystem is read-only", path.getFullPath().c_str()));
      return NULL;
   }

   if (fs != NULL)
      return static_cast<File*>(fs->create(np,FileNode::File).getPointer());
   return NULL;
}
Ejemplo n.º 4
0
DirectoryRef MountSystem::createDirectory(const Path& path, FileSystemRef fs)
{
   Path np = _normalize(path);
   if (fs.isNull())
      fs = _getFileSystemFromList(np);

   if (fs && fs->isReadOnly())
   {
      _log(String::ToString("Cannot create directory %s, filesystem is read-only", path.getFullPath().c_str()));
      return NULL;
   }

   if (fs != NULL)
      return static_cast<Directory*>(fs->create(np,FileNode::Directory).getPointer());
   return NULL;
}
Ejemplo n.º 5
0
bool MountSystem::isReadOnly(const Path& path)
{
   // first check to see if filesystem is read only
   FileSystemRef fs = getFileSystem(path);
   if ( fs.isNull() )
      // no filesystem owns this file...oh well, return false
      return false;
   if (fs->isReadOnly())
      return true;

   // check the file attributes, note that if the file does not exist,
   // this function returns false.  that should be ok since we know
   // the file system is writable at this point.
   FileNode::Attributes attr;
   if (getFileAttributes(path,&attr))
      return attr.flags & FileNode::ReadOnly;
   return false;
}