Exemplo n.º 1
0
FileNodeRef FileSystemRedirect::create(const Path& path,FileNode::Mode mode)
{
   Path p = _merge(path);
   FileSystemRef fs = mMFS->getFileSystem(p);
   if (fs != NULL)
      return fs->create(p,mode);
   return NULL;
}
Exemplo n.º 2
0
Path FileSystemRedirect::mapFrom(const Path& path)
{
   Path p = _merge(path);
   FileSystemRef fs = mMFS->getFileSystem(p);
   if (fs != NULL)
      return fs->mapFrom(p);
   return NULL;
}
Exemplo n.º 3
0
bool FileSystemRedirect::remove(const Path& path)
{
   Path p = _merge(path);
   FileSystemRef fs = mMFS->getFileSystem(p);
   if (fs != NULL)
      return fs->remove(p);
   return false;
}
Exemplo n.º 4
0
FileNodeRef FileSystemRedirect::resolve(const Path& path)
{
   Path p = _merge(path);
   FileSystemRef fs = mMFS->getFileSystem(p);
   if (fs != NULL)
      return fs->resolve(p);
   return NULL;
}
Exemplo n.º 5
0
FileNodeRef MountSystem::getFileNode(const Path& path)
{
   Path np = _normalize(path);
   FileSystemRef fs = _getFileSystemFromList(np);
   if (fs != NULL)
      return fs->resolve(np);
   return NULL;
}
Exemplo n.º 6
0
/// Makes sure paths going in and out of the notifier will have the same format
String FileSystemChangeNotifier::cleanPath(const Path& dir)
{
   // This "cleans up" the path, if we don't do this we can get mismatches on the path
   // coming from the notifier
   FileSystemRef fs = Torque::FS::GetFileSystem(dir);
   if (!fs)
      return String::EmptyString;
   return fs->mapFrom(fs->mapTo(dir));
}
Exemplo n.º 7
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;
}
Exemplo n.º 8
0
bool GetFSPath( const Path &inPath, Path &outPath )
{
   FileSystemRef sys = GetFileSystem( inPath );
   if ( sys )
   {
      outPath = sys->mapTo( inPath );
      return true;
   }

   return false;
}
Exemplo n.º 9
0
bool FileSystemRedirectChangeNotifier::removeNotification( const Path &path, ChangeDelegate callback )
{
   FileSystemRedirect *rfs = (FileSystemRedirect*)mFS;
   Path redirectPath = rfs->_merge( path );

  FileSystemRef fs = rfs->mMFS->getFileSystem( redirectPath ); 
   if ( !fs || !fs->getChangeNotifier() )
      return false;

   return fs->getChangeNotifier()->removeNotification( redirectPath, callback );
}
Exemplo n.º 10
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;
}
Exemplo n.º 11
0
bool  MountSystem::mapFSPath( const String &inRoot, const Path &inPath, Path &outPath )
{
   FileSystemRef fs = _getFileSystemFromList(inRoot);

   if ( fs == NULL )
   {
      outPath = Path();
      return false;
   }

   outPath = fs->mapFrom( inPath );

   return outPath.getFullPath() != String();
}
Exemplo n.º 12
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;
}
Exemplo n.º 13
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;
}
Exemplo n.º 14
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;
}
Exemplo n.º 15
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;
}
Exemplo n.º 16
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;
   }
}
Exemplo n.º 17
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);
}
Exemplo n.º 18
0
      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;
      }