mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-07-12 04:58:32 +00:00
Add OMI-lib to solution and remove ARC implementations from PCKStudio and use OMI arc implementation
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PckStudio.Classes.FileTypes
|
||||
{
|
||||
// filepath to file data
|
||||
public class ConsoleArchive : Dictionary<string, byte[]>
|
||||
{
|
||||
public int SizeOfFile(string filepath) => this[filepath].Length;
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
|
||||
namespace PckStudio.Classes.IO.ARC
|
||||
{
|
||||
internal class ARCFileReader : StreamDataReader<ConsoleArchive>
|
||||
{
|
||||
public static ConsoleArchive Read(Stream stream, bool useLittleEndian = false)
|
||||
{
|
||||
return new ARCFileReader(useLittleEndian).ReadFromStream(stream);
|
||||
}
|
||||
|
||||
private ARCFileReader(bool useLittleEndian) : base(useLittleEndian)
|
||||
{
|
||||
}
|
||||
|
||||
protected override ConsoleArchive ReadFromStream(Stream stream)
|
||||
{
|
||||
ConsoleArchive _archive = new ConsoleArchive();
|
||||
int numberOfFiles = ReadInt(stream);
|
||||
for(int i = 0; i < numberOfFiles; i++)
|
||||
{
|
||||
string name = ReadString(stream);
|
||||
int offset = ReadInt(stream);
|
||||
int size = ReadInt(stream);
|
||||
_archive[name] = ReadBytesFromPosition(stream, offset, size);
|
||||
}
|
||||
return _archive;
|
||||
}
|
||||
|
||||
private string ReadString(Stream stream)
|
||||
{
|
||||
short length = ReadShort(stream);
|
||||
return ReadString(stream, length, Encoding.UTF8);
|
||||
}
|
||||
|
||||
private byte[] ReadBytesFromPosition(Stream stream, int position, int size)
|
||||
{
|
||||
long originalPOS = stream.Position;
|
||||
if (stream.Seek(position, SeekOrigin.Begin) != position) throw new Exception();
|
||||
byte[] data = ReadBytes(stream, size);
|
||||
if (stream.Seek(originalPOS, SeekOrigin.Begin) != originalPOS) throw new Exception();
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
|
||||
namespace PckStudio.Classes.IO.ARC
|
||||
{
|
||||
internal class ARCFileWriter : StreamDataWriter
|
||||
{
|
||||
private ConsoleArchive _archive;
|
||||
|
||||
public static void Write(Stream stream, ConsoleArchive archive, bool useLittleEndian = false)
|
||||
{
|
||||
new ARCFileWriter(archive, useLittleEndian).WriteToStream(stream);
|
||||
}
|
||||
|
||||
public ARCFileWriter(ConsoleArchive archive, bool useLittleEndian) : base(useLittleEndian)
|
||||
{
|
||||
_archive = archive;
|
||||
}
|
||||
|
||||
protected override void WriteToStream(Stream stream)
|
||||
{
|
||||
var arc = _archive.ToArray();
|
||||
WriteInt(stream, arc.Length);
|
||||
int offset = 4 + arc.Sum(pair => 10 + pair.Key.Length);
|
||||
foreach (var pair in arc)
|
||||
{
|
||||
int size = pair.Value.Length;
|
||||
WriteString(stream, pair.Key);
|
||||
WriteInt(stream, offset);
|
||||
WriteInt(stream, size);
|
||||
offset += size;
|
||||
}
|
||||
foreach (var pair in arc)
|
||||
{
|
||||
WriteBytes(stream, pair.Value);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteString(Stream stream, string s)
|
||||
{
|
||||
WriteShort(stream, (short)s.Length);
|
||||
WriteString(stream, s, Encoding.ASCII);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using PckStudio.Classes.IO.ARC;
|
||||
using OMI.Workers.Archive;
|
||||
using System.IO;
|
||||
|
||||
namespace PckStudio.Classes.Utils.ARC
|
||||
@@ -7,10 +7,12 @@ namespace PckStudio.Classes.Utils.ARC
|
||||
{
|
||||
public static void Inject(Stream stream, (string filepath, byte[] data) entry)
|
||||
{
|
||||
var archive = ARCFileReader.Read(stream);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
var reader = new ARCFileReader();
|
||||
var archive = reader.FromStream(stream);
|
||||
archive.Add(entry.filepath, entry.data);
|
||||
ARCFileWriter.Write(stream, archive);
|
||||
var writer = new ARCFileWriter(archive);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
writer.WriteToStream(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,9 @@ using System.Diagnostics;
|
||||
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using PckStudio.Classes.IO.PCK;
|
||||
using PckStudio.Classes.IO.ARC;
|
||||
using PckStudio.Classes.Misc;
|
||||
using OMI.Formats.Archive;
|
||||
using OMI.Workers.Archive;
|
||||
|
||||
namespace PckStudio.Forms
|
||||
{
|
||||
@@ -439,7 +440,8 @@ namespace PckStudio.Forms
|
||||
{
|
||||
using (FTPClient client = new FTPClient("ftp://" + textBoxHost.Text, "", "a3262443"))
|
||||
client.DownloadFile(dlcPath + "../../Common/Media/MediaWiiU.arc", Program.AppData + "MediaWiiU.arc");
|
||||
archive = ARCFileReader.Read(new MemoryStream(File.ReadAllBytes(Program.AppData + "MediaWiiU.arc")));
|
||||
var reader = new ARCFileReader();
|
||||
archive = reader.FromStream(new MemoryStream(File.ReadAllBytes(Program.AppData + "MediaWiiU.arc")));
|
||||
}
|
||||
|
||||
private void ReplacePackImage(string PackID)
|
||||
@@ -455,7 +457,8 @@ namespace PckStudio.Forms
|
||||
using (FTPClient client = new FTPClient("ftp://" + textBoxHost.Text, "", "a3262443"))
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ARCFileWriter.Write(ms, archive);
|
||||
var writer = new ARCFileWriter(archive);
|
||||
writer.WriteToStream(ms);
|
||||
File.WriteAllBytes(Program.AppData + "MediaWiiU.arc", ms.ToArray());
|
||||
client.UploadFile(Program.AppData + "MediaWiiU.arc", dlcPath + "../../Common/Media/MediaWiiU.arc");
|
||||
archive.Clear();
|
||||
|
||||
@@ -170,7 +170,6 @@
|
||||
<Compile Include="Classes\API\PCKCenter\PCKCollections.cs" />
|
||||
<Compile Include="Classes\API\PCKCenter\PCKCollectionsLocal.cs" />
|
||||
<Compile Include="Classes\API\PCKCenter\SaveLocalJSON.cs" />
|
||||
<Compile Include="Classes\FileTypes\ARCFile.cs" />
|
||||
<Compile Include="Classes\FileTypes\MaterialsFile.cs" />
|
||||
<Compile Include="Classes\FileTypes\BehaviourFile.cs" />
|
||||
<Compile Include="Classes\FileTypes\CSMBFile.cs" />
|
||||
@@ -180,8 +179,6 @@
|
||||
<Compile Include="Classes\FileTypes\COLFile.cs" />
|
||||
<Compile Include="Classes\FileTypes\CSM.cs" />
|
||||
<Compile Include="Classes\FileTypes\GRFFile.cs" />
|
||||
<Compile Include="Classes\IO\ARC\ARCFileWriter.cs" />
|
||||
<Compile Include="Classes\IO\ARC\ARCFileReader.cs" />
|
||||
<Compile Include="Classes\IO\Behaviour\BehavioursReader.cs" />
|
||||
<Compile Include="Classes\IO\Behaviour\BehavioursWriter.cs" />
|
||||
<Compile Include="Classes\IO\CSMB\CSMBFileReader.cs" />
|
||||
@@ -788,7 +785,12 @@
|
||||
<Version>4.5.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Vendor\OMI-Lib\OMI Filetypes Library\OMI Filetype Library.csproj">
|
||||
<Project>{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}</Project>
|
||||
<Name>OMI Filetype Library</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
@@ -5,6 +5,10 @@ VisualStudioVersion = 17.1.32414.318
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PckStudio", "PCK-Studio\PckStudio.csproj", "{0ACAAEDE-93F5-4B5D-B8D7-A0C43359C0D6}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Vendor", "Vendor", "{FC87F3E5-B07E-4FFB-889F-66FA3A3CFCAA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OMI Filetype Library", "Vendor\OMI-Lib\OMI Filetypes Library\OMI Filetype Library.csproj", "{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -27,10 +31,25 @@ Global
|
||||
{0ACAAEDE-93F5-4B5D-B8D7-A0C43359C0D6}.Release|x64.Build.0 = Release|Any CPU
|
||||
{0ACAAEDE-93F5-4B5D-B8D7-A0C43359C0D6}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{0ACAAEDE-93F5-4B5D-B8D7-A0C43359C0D6}.Release|x86.Build.0 = Release|Any CPU
|
||||
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Release|x64.Build.0 = Release|Any CPU
|
||||
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB} = {FC87F3E5-B07E-4FFB-889F-66FA3A3CFCAA}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {9A3BF1FB-950F-401E-9F58-EA7BBADCE6F2}
|
||||
EndGlobalSection
|
||||
|
||||
Reference in New Issue
Block a user