From f5ca10d4b2d1f7444e88059d9d21201b16f63f95 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Sun, 22 Sep 2019 13:18:05 -0400 Subject: [PATCH] Add support for vibs vibration archives --- .../FileFormats/Archives/VIBS.cs | 99 +++++++++++++++++++ .../File_Format_Library.csproj | 1 + File_Format_Library/Main.cs | 1 + 3 files changed, 101 insertions(+) create mode 100644 File_Format_Library/FileFormats/Archives/VIBS.cs diff --git a/File_Format_Library/FileFormats/Archives/VIBS.cs b/File_Format_Library/FileFormats/Archives/VIBS.cs new file mode 100644 index 00000000..aa8b5a65 --- /dev/null +++ b/File_Format_Library/FileFormats/Archives/VIBS.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Toolbox; +using System.Windows.Forms; +using Toolbox.Library; +using Toolbox.Library.IO; + +namespace FirstPlugin +{ + public class VIBS : IArchiveFile, IFileFormat + { + public FileType FileType { get; set; } = FileType.Archive; + + public bool CanSave { get; set; } + public string[] Description { get; set; } = new string[] { "Joycon Vibration Archive" }; + public string[] Extension { get; set; } = new string[] { "*.vibs" }; + public string FileName { get; set; } + public string FilePath { get; set; } + public IFileInfo IFileInfo { get; set; } + + public bool CanAddFiles { get; set; } + public bool CanRenameFiles { get; set; } + public bool CanReplaceFiles { get; set; } + public bool CanDeleteFiles { get; set; } + + public bool Identify(System.IO.Stream stream) + { + return Utils.GetExtension(FileName) == ".vibs"; + } + + public Type[] Types + { + get + { + List types = new List(); + return types.ToArray(); + } + } + + public List files = new List(); + + public IEnumerable Files => files; + + public void ClearFiles() { files.Clear(); } + + public void Load(System.IO.Stream stream) + { + using (var reader = new FileReader(stream)) + { + reader.SetByteOrder(false); + uint version = reader.ReadUInt32(); + uint numEntries = reader.ReadUInt32(); + + for (int i = 0; i < numEntries; i++) + { + var file = new FileEntry(); + file.FileName = reader.ReadString(24, true); + uint unk = reader.ReadUInt32(); // 8 + uint unk2 = reader.ReadUInt32(); // 12 + uint dataLength = reader.ReadUInt32(); + uint index = reader.ReadUInt32(); + uint dataOffset = reader.ReadUInt32(); + files.Add(file); + + using (reader.TemporarySeek(dataOffset, System.IO.SeekOrigin.Begin)) { + file.FileData = reader.ReadBytes((int)dataLength); + } + } + } + } + + public void Unload() + { + + } + + public void Save(System.IO.Stream stream) + { + } + + public bool AddFile(ArchiveFileInfo archiveFileInfo) + { + return false; + } + + public bool DeleteFile(ArchiveFileInfo archiveFileInfo) + { + return false; + } + + public class FileEntry : ArchiveFileInfo + { + + } + } +} diff --git a/File_Format_Library/File_Format_Library.csproj b/File_Format_Library/File_Format_Library.csproj index 4b44266a..a94e81db 100644 --- a/File_Format_Library/File_Format_Library.csproj +++ b/File_Format_Library/File_Format_Library.csproj @@ -215,6 +215,7 @@ + diff --git a/File_Format_Library/Main.cs b/File_Format_Library/Main.cs index 571167e9..e04eaa0a 100644 --- a/File_Format_Library/Main.cs +++ b/File_Format_Library/Main.cs @@ -388,6 +388,7 @@ namespace FirstPlugin Formats.Add(typeof(DAT_Bayonetta)); Formats.Add(typeof(XCI)); Formats.Add(typeof(TVOL)); + Formats.Add(typeof(VIBS)); // Formats.Add(typeof(MSBP)); // Formats.Add(typeof(BFGRP));