Example #1
0
bool FileSystemRedirect::rename(const Path& a,const Path& b)
{
   Path na = _merge(a);
   Path nb = _merge(b);
   FileSystemRef fsa = mMFS->getFileSystem(na);
   FileSystemRef fsb = mMFS->getFileSystem(nb);
   if (fsa.getPointer() == fsb.getPointer())
      return fsa->rename(na,nb);
   return false;
}
Example #2
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);
}
Example #3
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;
}
      bool VirtualMountSystem::unmount(FileSystemRef fs)
      {
         bool unmounted = Parent::unmount(fs);
         if (!unmounted)
            return false;

         // this is a linear time operation, because we have to search every path in all roots 
         // to remove references to the fs.
         // contant time operation can be achieved be using the unmount(string) version, which unmounts all 
         // filesystems for a given root and so doesn't need to do any searching.
         U32 start = Platform::GetPlatform()->getRealMilliseconds();
         for (RootToPathFSMap::Iterator riter = mMountMap.begin();
            riter != mMountMap.end();
            ++riter)
         {
            PathFSMap* rootDict = (*riter).value;
            for (PathFSMap::Iterator piter = rootDict->begin();
               piter != rootDict->end();
               ++piter)
            {
               Vector<FileSystemRef>& plist = (*piter).value;
               for (S32 i = plist.size() - 1;
                  i >= 0;
                  i--)
               {
                  if (plist[i].getPointer() == fs.getPointer())
                     plist.erase(i);
               }
            }
         }

         if (gVMSVerboseLog)
            _log(String::ToString("Unmounted virtual file system in %ums", Platform::GetPlatform()->getRealMilliseconds() - start));

         return true;
      }