public PersistentContainerSettings(int pageSize = 4096, PersistentContainerFlags flags = 0, PersistentContainerCompressType compressType = PersistentContainerCompressType.None) { Extenders.ValidatePageSize(pageSize); PageSize = pageSize; Flags = flags; CompressType = compressType; }
internal PagedContainerHeader(Stream stm, IEncryptorDecryptor encryptorDecryptor) { if (stm.Length < HEADER_PART) { throw new InvalidDataException("PagedContainerHeader: File corrupted (too small)"); } stm.Position = 0; var buff = new byte[HEADER_PART]; stm.Read(buff, 0, buff.Length); int offset = 0; var sign = buff.GetInt(ref offset); // 4 byte if (sign != SIGN) { throw new InvalidDataException($"PagedContainerHeader: File corruped (signature {sign:X}h invalid, must be {SIGN:X}h)"); } PageSize = buff.GetInt(ref offset); // 4 byte PageUserDataSize = PageSize - 4; Extenders.ValidatePageSize(PageSize); DirectoryFirstPage = buff.GetInt(ref offset); // 4 byte if (DirectoryFirstPage < 0) { throw new InvalidDataException($"PagedContainerHeader: DirectoryFirstPage has invalid value ({DirectoryFirstPage})"); } Flags = (PersistentContainerFlags)(buff.GetUInt16(ref offset) & 0xFFFF); var flagsData = buff[offset]; CompressType = (PersistentContainerCompressType)flagsData; DataHandler = getDataHandler(CompressType, encryptorDecryptor); }