Пример #1
0
        public IsoResourceAccessor(IsoResourceProvider isoProvider, IsoResourceProxy isoProxy, string pathToDirOrFile)
        {
            if (!pathToDirOrFile.StartsWith("/"))
            {
                throw new ArgumentException("Wrong path '{0}': Path in ISO file must start with a '/' character", pathToDirOrFile);
            }
            _isoProxy = isoProxy;
            _isoProxy.IncUsage();
            try
            {
                _isoProvider     = isoProvider;
                _pathToDirOrFile = pathToDirOrFile;

                _isDirectory = true;
                _lastChanged = _isoProxy.IsoFileResourceAccessor.LastChanged;
                _size        = -1;

                if (IsEmptyOrRoot)
                {
                    return;
                }
                lock (_isoProxy.SyncObj)
                {
                    string isoPath = ToIsoPath(pathToDirOrFile);
                    if (_isoProxy.DiskFileSystem.FileExists(isoPath))
                    {
                        _isDirectory = false;
                        _size        = _isoProxy.DiskFileSystem.GetFileLength(isoPath);
                        _lastChanged = _isoProxy.DiskFileSystem.GetLastWriteTime(isoPath);
                        return;
                    }
                    if (_isoProxy.DiskFileSystem.DirectoryExists(isoPath))
                    {
                        _isDirectory = true;
                        _size        = -1;
                        _lastChanged = _isoProxy.DiskFileSystem.GetLastWriteTime(isoPath);
                        return;
                    }
                    throw new ArgumentException(string.Format("IsoResourceAccessor cannot access path or file '{0}' in iso-file", isoPath));
                }
            }
            catch (Exception)
            {
                _isoProxy.DecUsage();
                throw;
            }
        }
    public IsoResourceAccessor(IsoResourceProvider isoProvider, IsoResourceProxy isoProxy, string pathToDirOrFile)
    {
      if (!pathToDirOrFile.StartsWith("/"))
        throw new ArgumentException("Wrong path '{0}': Path in ISO file must start with a '/' character", pathToDirOrFile);
      _isoProxy = isoProxy;
      _isoProxy.IncUsage();
      try
      {
        _isoProvider = isoProvider;
        _pathToDirOrFile = pathToDirOrFile;

        _isDirectory = true;
        _lastChanged = _isoProxy.IsoFileResourceAccessor.LastChanged;
        _size = -1;

        if (IsEmptyOrRoot)
          return;
        lock (_isoProxy.SyncObj)
        {
          string isoPath = ToIsoPath(pathToDirOrFile);
          if (_isoProxy.DiskFileSystem.FileExists(isoPath))
          {
            _isDirectory = false;
            _size = _isoProxy.DiskFileSystem.GetFileLength(isoPath);
            _lastChanged = _isoProxy.DiskFileSystem.GetLastWriteTime(isoPath);
            return;
          }
          if (_isoProxy.DiskFileSystem.DirectoryExists(isoPath))
          {
            _isDirectory = true;
            _size = -1;
            _lastChanged = _isoProxy.DiskFileSystem.GetLastWriteTime(isoPath);
            return;
          }
          throw new ArgumentException(string.Format("IsoResourceAccessor cannot access path or file '{0}' in iso-file", isoPath));
        }
      }
      catch (Exception)
      {
        _isoProxy.DecUsage();
        throw;
      }
    }