예제 #1
0
bool MountSystem::unmount(FileSystemRef fs)
{
   if (fs.isNull())
      return false;

   // iterate back to front in case FS is in list multiple times.
   // also check that fs is not null each time since its a strong ref
   // so it could be nulled during removal.
   bool unmounted = false;
   for (S32 i = mMountList.size() - 1; !fs.isNull() && i >= 0; --i)
   {
      if (mMountList[i].fileSystem.getPointer() == fs.getPointer())
      {
         mMountList.erase(i);
         unmounted = true;
      }
   }
   return unmounted;
}
예제 #2
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;
}
예제 #3
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;
}
예제 #4
0
bool MountSystem::isDirectory(const Path& path, FileSystemRef fsRef)
{
   FileNode::Attributes attr;

   if (fsRef.isNull())
   {
      if (getFileAttributes(path,&attr))
         return attr.flags & FileNode::Directory;
      return false;
   }
   else
   {
      FileNodeRef fnRef = fsRef->resolve(path);
      if (fnRef.isNull())
         return false;

      FileNode::Attributes attr;
      if (fnRef->getAttributes(&attr))
         return attr.flags & FileNode::Directory;
      return false;
   }
}