public StructColor(ArkArchive archive, ArkName structType) : base(structType) { B = archive.GetByte(); G = archive.GetByte(); R = archive.GetByte(); A = archive.GetByte(); }
public static T ReadBinary <T>(this IConversionSupport conversionSupport, string filePath, ReadingOptions readingOptions) where T : IConversionSupport { if (new FileInfo(filePath).Length > int.MaxValue) { throw new Exception("Input file is too large."); } Stream stream; if (readingOptions.UsesMemoryMapping) { MemoryMappedFile memoryMappedFile = MemoryMappedFile.CreateFromFile(filePath); stream = memoryMappedFile.CreateViewStream(); } else { stream = new MemoryStream(File.ReadAllBytes(filePath)); } using (ArkArchive archive = new ArkArchive(stream)) { conversionSupport.ReadBinary(archive, readingOptions); } return((T)conversionSupport); }
public override void Init(ArkArchive archive) { B = archive.ReadByte(); G = archive.ReadByte(); R = archive.ReadByte(); A = archive.ReadByte(); }
//public int getSize(bool nameTable) //{ // return _fromEnum ? ArkArchive.GetNameLength(_nameValue, nameTable) : 1; //} public void read(ArkArchive archive, ArkName enumName, bool propertyIsExcluded = false) { _enumName = enumName; _fromEnum = !enumName.Equals(ArkName.NONE_NAME); if (propertyIsExcluded) { if (_fromEnum) { archive.SkipName(); } else { archive.Position += 1; } } else { if (_fromEnum) { _nameValue = archive.GetName(); } else { _byteValue = archive.GetByte(); } } }
private void readBinary(ArkArchive archive) { if (Length >= 8) { ObjectType = archive.ReadInt(); switch (ObjectType) { case TypeId: ObjectId = archive.ReadInt(); break; case TypePath: ObjectString = archive.ReadName(); break; default: archive.Position = archive.Position - 4; ObjectType = TypePathNoType; ObjectString = archive.ReadName(); break; } } else if (Length == 4) { // Only seems to happen in Version 5 ObjectType = TypeId; ObjectId = archive.ReadInt(); } else { Debug.WriteLine($"Warning: ObjectReference with length value {Length} at {archive.Position:X}"); archive.Position = archive.Position + Length; } }
public override void WriteBinary(ArkArchive archive) { archive.WriteFloat(R); archive.WriteFloat(G); archive.WriteFloat(B); archive.WriteFloat(A); }
public static void WriteBinary(this IConversionSupport conversionSupport, string filePath, WritingOptions writingOptions) { int size = conversionSupport.CalculateSize(); Stream stream; if (writingOptions.UsesMemoryMapping) { File.Create(filePath).Dispose(); MemoryMappedFile memoryMappedFile = MemoryMappedFile.CreateFromFile(filePath, FileMode.Open, null, size, MemoryMappedFileAccess.Write); stream = memoryMappedFile.CreateViewStream(); } else { stream = new MemoryStream(new byte[size], true); } using (ArkArchive archive = new ArkArchive(stream)) { conversionSupport.WriteBinary(archive, writingOptions); if (!writingOptions.UsesMemoryMapping) { using (FileStream file = File.Create(filePath)) { stream.Position = 0; stream.CopyTo(file); } } } }
public PropertyBase(ArkArchive archive, PropertyArgs args) { Name = args.Name; TypeName = args.TypeName; DataSize = archive.GetInt(); Index = archive.GetInt(); }
public override void Init(ArkArchive archive, ArkName name) { base.Init(archive, name); ArkName arrayType = archive.ReadName(); long position = archive.Position; try { Value = ArkArrayRegistry.ReadBinary(archive, arrayType, this); if (Value == null) { throw new UnreadablePropertyException("ArkArrayRegistry returned null"); } } catch (UnreadablePropertyException upe) { archive.Position = position; Value = new ArkArrayUnknown(archive, DataSize, arrayType); archive.HasUnknownNames = true; Debug.WriteLine($"Reading ArrayProperty of type {arrayType} with name {name} as byte blob because:"); Debug.WriteLine(upe.Message); Debug.WriteLine(upe.StackTrace); } }
public void Read(ArkArchive archive) { if (Length >= 8) { ObjectType = archive.GetInt(); if (ObjectType == TYPE_ID) { ObjectId = archive.GetInt(); } else if (ObjectType == TYPE_PATH) { ObjectString = archive.GetName(); } else { //No longer used: ObjectReference with possibly unknown type {objectType} at {archive.Position:X}; archive.Position -= 4; ObjectType = TYPE_PATH_NO_TYPE; ObjectString = archive.GetName(); } } else if (Length == 4) { // Only seems to happen in Version 5 ObjectType = TYPE_ID; ObjectId = archive.GetInt(); } else { _logger.Warn($"ObjectReference with length value {Length} at {archive.Position:X}"); archive.Position += Length; } }
public static IProperty ReadBinary(ArkArchive archive) { ArkName name = archive.ReadName(); if (name == null || string.IsNullOrEmpty(name.ToString())) { archive.HasUnknownData = true; throw new UnreadablePropertyException( $"Property name is {(name == null ? "null" : "empty")}, indicating a corrupt file. Ignoring remaining properties."); } if (name == ArkName.NameNone) { return(null); } ArkName type = archive.ReadName(); if (type != null && typeMap.TryGetValue(type, out PropertyConstructor constructor)) { return(constructor.BinaryConstructor(archive, name)); } archive.DebugMessage($"Unknown property type {name}"); archive.HasUnknownNames = true; return(new PropertyUnknown(archive, name)); }
public override void WriteBinary(ArkArchive archive) { archive.WriteFloat(X); archive.WriteFloat(Y); archive.WriteFloat(Z); archive.WriteFloat(W); }
public override void Init(ArkArchive archive, PropertyArray property) { int size = archive.ReadInt(); ArkName structType = StructRegistry.MapArrayNameToTypeName(property.Name); if (structType == null) { if (size * 4 + 4 == property.DataSize) { structType = color; } else if (size * 12 + 4 == property.DataSize) { structType = vector; } else if (size * 16 + 4 == property.DataSize) { structType = linearColor; } } for (int n = 0; n < size; n++) { Add(StructRegistry.ReadBinary(archive, structType)); } }
public override void Init(ArkArchive archive) { X = archive.ReadFloat(); Y = archive.ReadFloat(); Z = archive.ReadFloat(); W = archive.ReadFloat(); }
public StructLinearColor(ArkArchive archive, ArkName structType) : base(structType) { R = archive.GetFloat(); G = archive.GetFloat(); B = archive.GetFloat(); A = archive.GetFloat(); }
public void WriteBinary(ArkArchive archive) { if (Data != null) { archive.WriteBytes(Data); } }
public override void Init(ArkArchive archive) { R = archive.ReadFloat(); G = archive.ReadFloat(); B = archive.ReadFloat(); A = archive.ReadFloat(); }
public PropertyArray(ArkArchive archive, PropertyArgs args, bool propertyIsExcluded = false) : base(archive, args, propertyIsExcluded) { if (propertyIsExcluded) { archive.SkipName(); archive.Position += DataSize; return; } ArrayType = archive.GetName(); var position = archive.Position; try { _value = ArkArrayRegistry.read(archive, ArrayType, DataSize); if (_value == null) { throw new UnreadablePropertyException(); } } catch (UnreadablePropertyException) { archive.Position += DataSize; _logger.Error($"Unreadable ArrayProperty with name {Name}, skipping."); throw new UnreadablePropertyException(); } }
public StructQuat(ArkArchive archive, ArkName structType) : base(structType) { X = archive.GetFloat(); Y = archive.GetFloat(); Z = archive.GetFloat(); W = archive.GetFloat(); }
public override void WriteBinary(ArkArchive archive) { archive.WriteByte(B); archive.WriteByte(G); archive.WriteByte(R); archive.WriteByte(A); }
public override void WriteBinary(ArkArchive archive) { archive.WriteInt(Count); foreach (ArkByteValue bv in this) { archive.WriteName(bv.NameValue); } }
//public long Size //{ // get // { // return Float.BYTES * 6; // } //} public void read(ArkArchive archive) { X = archive.GetFloat(); Y = archive.GetFloat(); Z = archive.GetFloat(); Pitch = archive.GetFloat(); Yaw = archive.GetFloat(); Roll = archive.GetFloat(); }
//private static long serialVersionUID = 1L; public override void Init(ArkArchive archive, PropertyArray property) { int size = archive.ReadInt(); for (int n = 0; n < size; n++) { Add(archive.ReadShort()); } }
public void WriteBinary(ArkArchive archive) { archive.WriteName(Name); archive.WriteName(Type); archive.WriteInt(DataSize); archive.WriteInt(Index); writeBinaryValue(archive); }
public ArkArrayInt16(ArkArchive archive, int dataSize) { var size = archive.GetInt(); for (int n = 0; n < size; n++) { Add(archive.GetShort()); } }
public ArkArrayObjectReference(ArkArchive archive, int dataSize) { var size = archive.GetInt(); for (int n = 0; n < size; n++) { Add(new ObjectReference(archive, 8)); // Fixed size? } }
public ArkArrayBool(ArkArchive archive, int dataSize) { var size = archive.GetInt(); for (int n = 0; n < size; n++) { Add(archive.GetByte() != 0); } }
public ArkArrayDouble(ArkArchive archive, int dataSize) { var size = archive.GetInt(); for (int n = 0; n < size; n++) { Add(archive.GetDouble()); } }
//private static long serialVersionUID = 1L; public override void Init(ArkArchive archive, PropertyArray property) { int size = archive.ReadInt(); for (int n = 0; n < size; n++) { Add(new ObjectReference(archive, 8)); // Fixed size? } }
public ArkArrayInteger(ArkArchive archive, int dataSize) { int size = archive.GetInt(); for (int n = 0; n < size; n++) { Add(archive.GetInt()); } }