protected virtual void LoadChanges(IList <Subtitle> subtitles) { if (HasChanges) { using (var fs = new FileStream(ChangesFile, FileMode.Open)) using (var input = new ExtendedBinaryReader(fs, Encoding.Unicode)) { var version = input.ReadInt32(); if (version != ChangesFileVersion) { //File.Delete(ChangesFile); return; } var subtitleCount = input.ReadInt32(); for (var i = 0; i < subtitleCount; i++) { var offset = input.ReadInt64(); var text = input.ReadString(); var subtitle = subtitles.FirstOrDefault(x => x.Offset == offset); if (subtitle != null) { subtitle.PropertyChanged -= SubtitlePropertyChanged; subtitle.Translation = text; subtitle.Loaded = subtitle.Translation; subtitle.PropertyChanged += SubtitlePropertyChanged; } } } } }
// for the SA reader public SaIndex(ExtendedBinaryReader reader) { var header = reader.ReadString(); var version = reader.ReadUInt16(); reader.ReadInt64(); // skip timestamp RefSeqName = reader.ReadString(); SupplementaryAnnotationCommon.CheckGuard(reader); if (header != SupplementaryAnnotationCommon.IndexHeader || version != SupplementaryAnnotationCommon.IndexVersion) { throw new UserErrorException($"The header check failed for the supplementary annotation index file ({reader.BaseStream}): ID: exp: {SupplementaryAnnotationCommon.IndexHeader} obs: {header}, version: exp: {SupplementaryAnnotationCommon.IndexVersion} obs: {version}"); } var count = reader.ReadInt32(); _saIndexNodes = new SaIndexNode[count]; for (var i = 0; i < count; i++) { _saIndexNodes[i] = new SaIndexNode(reader); } SupplementaryAnnotationCommon.CheckGuard(reader); }
private void ReadHeader() { var header = _reader.ReadString(); if (header != CustomIntervalCommon.DataHeader) { throw new GeneralException("Unrecognized header in custom interval database"); } var schema = _reader.ReadUInt16(); if (schema != CustomIntervalCommon.SchemaVersion) { throw new GeneralException( $"Custom interval database schema mismatch. Expected {CustomIntervalCommon.SchemaVersion}, observed {schema}"); } _creationTime = _reader.ReadInt64(); _referenceName = _reader.ReadString(); _intervalType = _reader.ReadString(); DataVersion = new DataSourceVersion(_reader); CheckGuard(); }
public static ProcessInvocationEndEvent ReadProcessInvocationEndEvent(ExtendedBinaryReader reader) { return(new ProcessInvocationEndEvent { InvocationUID = reader.Read7BitEncodedInt(), ElapsedMilliseconds = reader.ReadInt64(), NetTimeMilliseconds = reader.ReadNullableInt64(), }); }
private AssetsFile(string path) { this.path = path; buf = new ExtendedBinaryReader(File.OpenRead(path)); basepath = Path.GetDirectoryName(path); buf.endian = EndianType.BigEndian; metadata_size = buf.ReadUInt32(); file_size = buf.ReadUInt32(); format = buf.ReadUInt32(); data_offset = buf.ReadUInt32(); if (format >= 9 && buf.ReadUInt32() == 0) { fileEndianType = EndianType.LittleEndian; } if (format >= 22) { metadata_size = buf.ReadUInt32(); file_size = buf.ReadInt64(); data_offset = buf.ReadInt64(); buf.BaseStream.Seek(8, SeekOrigin.Current); // Unknown value } buf.endian = fileEndianType; string versionString = buf.ReadNullTerminatedString(); versionString = versionString.Replace('p', '.'); versionString = versionString.Replace('f', '.'); version = new Version(versionString); platform = buf.ReadInt32(); buf.endian = EndianType.LittleEndian; typeMetaData = new TypeMetaData(format, buf); if (format >= 7 && format < 14) { longObjectIDs = buf.ReadInt32() != 0; } // Read obejct info table int objectCount = buf.ReadInt32(); // Save position for saving file objectsIndexOffset = buf.Position; var assetsDict = new Dictionary <long, AssetInfo>(objectCount); for (int i = 0; i < objectCount; i++) { var assetInfo = new AssetInfo(); assetInfo.asset = this; assetInfo.pathID = ReadPathID(); assetInfo.dataOffset = format >= 22 ? buf.ReadInt64() : buf.ReadUInt32(); assetInfo.size = buf.ReadUInt32(); assetInfo.typeID = buf.ReadInt32(); if (format < 16) { assetInfo.classID = buf.ReadUInt16(); } else { assetInfo.classID = typeMetaData.ClassIDs[assetInfo.typeID].classID; } if (format < 16) { assetInfo.isDestroyed = buf.ReadUInt16() != 0; } if (format == 15 || format == 16) { assetInfo.stripped = buf.ReadByte(); } assetsDict.Add(assetInfo.pathID, assetInfo); } assets = assetsDict; if (format >= 11) { int scriptCount = buf.ReadInt32(); scriptTypes = new List <ScriptType>(scriptCount); for (int i = 0; i < scriptCount; i++) { var add = new ScriptType { index = buf.ReadInt32(), ID = ReadPathID() }; scriptTypes.Add(add); } } if (format >= 6) { int referenceCount = buf.ReadInt32(); references = new List <AssetReference>(referenceCount); for (int i = 0; i < referenceCount; i++) { references.Add(AssetReference.Read(buf)); } } }