public HierarchicalIntegrityVerificationStorage(IntegrityVerificationInfo[] levelInfo, IntegrityCheckLevel integrityCheckLevel, bool leaveOpen)
        {
            Levels = new IStorage[levelInfo.Length];
            IntegrityCheckLevel = integrityCheckLevel;
            LevelValidities     = new Validity[levelInfo.Length - 1][];
            IntegrityStorages   = new IntegrityVerificationStorage[levelInfo.Length - 1];

            Levels[0] = levelInfo[0].Data;

            for (int i = 1; i < Levels.Length; i++)
            {
                var levelData = new IntegrityVerificationStorage(levelInfo[i], Levels[i - 1], integrityCheckLevel, leaveOpen);

                Levels[i] = new CachedStorage(levelData, 4, leaveOpen);
                LevelValidities[i - 1]   = levelData.BlockValidities;
                IntegrityStorages[i - 1] = levelData;
            }

            DataLevel = Levels[Levels.Length - 1];
            Length    = DataLevel.Length;

            if (!leaveOpen)
            {
                ToDispose.Add(DataLevel);
            }
        }
        public HierarchicalIntegrityVerificationStorage(IntegrityVerificationInfo[] levelInfo, IntegrityCheckLevel integrityCheckLevel, bool leaveOpen)
        {
            Levels = new IStorage[levelInfo.Length];
            IntegrityCheckLevel = integrityCheckLevel;
            LevelValidities     = new Validity[levelInfo.Length - 1][];
            IntegrityStorages   = new IntegrityVerificationStorage[levelInfo.Length - 1];

            Levels[0] = levelInfo[0].Data;

            for (int i = 1; i < Levels.Length; i++)
            {
                var levelData = new IntegrityVerificationStorage(levelInfo[i], Levels[i - 1], integrityCheckLevel, leaveOpen);

                int cacheCount = Math.Min((int)Util.DivideByRoundUp(levelData.GetSize(), levelInfo[i].BlockSize), 4);

                Levels[i] = new CachedStorage(levelData, cacheCount, leaveOpen);
                LevelValidities[i - 1]   = levelData.BlockValidities;
                IntegrityStorages[i - 1] = levelData;
            }

            DataLevel = Levels[Levels.Length - 1];
            _length   = DataLevel.GetSize();

            if (!leaveOpen)
            {
                ToDispose.Add(DataLevel);
            }
        }
示例#3
0
 public DirectorySaveDataFile(DirectorySaveDataFileSystem parentFs, IFile baseFile)
 {
     ParentFs = parentFs;
     BaseFile = baseFile;
     Mode     = BaseFile.Mode;
     ToDispose.Add(BaseFile);
 }
示例#4
0
 public SubStorage(IStorage baseStorage, long offset, long length, bool leaveOpen)
     : this(baseStorage, offset, length)
 {
     if (!leaveOpen)
     {
         ToDispose.Add(BaseStorage);
     }
 }
示例#5
0
 public StreamStorage(Stream baseStream, bool leaveOpen)
 {
     BaseStream = baseStream;
     _length    = BaseStream.Length;
     if (!leaveOpen)
     {
         ToDispose.Add(BaseStream);
     }
 }
示例#6
0
        public LocalStorage(string path, FileAccess access, FileMode mode)
        {
            Path    = path;
            Stream  = new FileStream(Path, mode, access);
            Storage = new StreamStorage(Stream, false);

            ToDispose.Add(Storage);
            ToDispose.Add(Stream);
        }
示例#7
0
        public LocalFile(string path, OpenMode mode)
        {
            Mode   = mode;
            Stream = OpenFile(path, mode);
            File   = new StreamFile(Stream, mode);

            ToDispose.Add(File);
            ToDispose.Add(Stream);
        }
示例#8
0
文件: LocalFile.cs 项目: AcK77/LibHac
        public LocalFile(string path, OpenMode mode)
        {
            Path   = path;
            Mode   = mode;
            Stream = new FileStream(Path, FileMode.Open, GetFileAccess(mode), GetFileShare(mode));
            File   = new StreamFile(Stream, mode);

            ToDispose.Add(File);
            ToDispose.Add(Stream);
        }
示例#9
0
        public SectorStorage(IStorage baseStorage, int sectorSize, bool leaveOpen)
        {
            BaseStorage = baseStorage;
            SectorSize  = sectorSize;
            SectorCount = (int)Util.DivideByRoundUp(BaseStorage.GetSize(), SectorSize);
            _length     = BaseStorage.GetSize();

            if (!leaveOpen)
            {
                ToDispose.Add(BaseStorage);
            }
        }
示例#10
0
        public JournalStorage(IStorage baseStorage, IStorage header, JournalMapParams mapInfo, bool leaveOpen)
        {
            BaseStorage   = baseStorage;
            HeaderStorage = header;
            Header        = new JournalHeader(HeaderStorage);

            IStorage mapHeader = header.Slice(0x20, 0x10);

            Map = new JournalMap(mapHeader, mapInfo);

            BlockSize = (int)Header.BlockSize;
            _length   = Header.TotalSize - Header.JournalSize;

            if (!leaveOpen)
            {
                ToDispose.Add(baseStorage);
            }
        }
示例#11
0
        public CachedStorage(IStorage baseStorage, int blockSize, int cacheSize, bool leaveOpen)
        {
            BaseStorage = baseStorage;
            BlockSize   = blockSize;
            Length      = BaseStorage.Length;

            if (!leaveOpen)
            {
                ToDispose.Add(BaseStorage);
            }

            for (int i = 0; i < cacheSize; i++)
            {
                var block = new CacheBlock {
                    Buffer = ArrayPool <byte> .Shared.Rent(blockSize)
                };
                Blocks.AddLast(block);
            }
        }
示例#12
0
        public CachedStorage(IStorage baseStorage, int blockSize, int cacheSize, bool leaveOpen)
        {
            BaseStorage = baseStorage;
            BlockSize   = blockSize;
            _length     = BaseStorage.GetSize();

            if (!leaveOpen)
            {
                ToDispose.Add(BaseStorage);
            }

            for (int i = 0; i < cacheSize; i++)
            {
                var block = new CacheBlock {
                    Buffer = new byte[blockSize], Index = -1
                };
                Blocks.AddLast(block);
            }
        }
示例#13
0
        /// <summary>
        /// Creates a new <see cref="RemapStorage"/>
        /// </summary>
        /// <param name="storage">A <see cref="IStorage"/> of the main data of the RemapStream.
        /// The <see cref="RemapStorage"/> object assumes complete ownership of the Storage.</param>
        /// <param name="header">The header for this RemapStorage.</param>
        /// <param name="mapEntries">The remapping entries for this RemapStorage.</param>
        /// <param name="leaveOpen"><see langword="true"/> to leave the storage open after the <see cref="RemapStorage"/> object is disposed; otherwise, <see langword="false"/>.</param>
        public RemapStorage(IStorage storage, IStorage header, IStorage mapEntries, bool leaveOpen)
        {
            BaseStorage     = storage;
            HeaderStorage   = header;
            MapEntryStorage = mapEntries;

            Header = new RemapHeader(HeaderStorage);

            MapEntries = new MapEntry[Header.MapEntryCount];
            var reader = new BinaryReader(MapEntryStorage.AsStream());

            for (int i = 0; i < Header.MapEntryCount; i++)
            {
                MapEntries[i] = new MapEntry(reader);
            }

            if (!leaveOpen)
            {
                ToDispose.Add(BaseStorage);
            }

            Segments = InitSegments(Header, MapEntries);
        }