From b2de507baf609cf204ae4b09c02034670ac87a5f Mon Sep 17 00:00:00 2001 From: SecreC Date: Fri, 22 Dec 2023 16:24:18 -0800 Subject: [PATCH] updated some method summaries forgot to change some of the ones I copypasted from bf --- .../SPD.File.Emulator.Interfaces/ISpdEmulator.cs | 2 +- Emulator/SPD.File.Emulator/SpdEmulator.cs | 6 +++--- Emulator/SPD.File.Emulator/SpdEmulatorApi.cs | 10 ++++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Emulator/Interfaces/SPD.File.Emulator.Interfaces/ISpdEmulator.cs b/Emulator/Interfaces/SPD.File.Emulator.Interfaces/ISpdEmulator.cs index 93013a6..9a84f5d 100644 --- a/Emulator/Interfaces/SPD.File.Emulator.Interfaces/ISpdEmulator.cs +++ b/Emulator/Interfaces/SPD.File.Emulator.Interfaces/ISpdEmulator.cs @@ -17,7 +17,7 @@ public interface ISpdEmulator public bool TryCreateFromFileSlice(string sourcePath, long offset, string route, string destinationPath); /// - /// Tries to create an emulated SPD file by compiling any applicable flow files using the input as the basee + /// Tries to create an emulated SPD file by merging any applicable sprite or texture files, using the input as the base /// /// Path to the SPD file to use as a base. /// The route of the emulated SPD file. diff --git a/Emulator/SPD.File.Emulator/SpdEmulator.cs b/Emulator/SPD.File.Emulator/SpdEmulator.cs index 757b2fe..10a07b4 100644 --- a/Emulator/SPD.File.Emulator/SpdEmulator.cs +++ b/Emulator/SPD.File.Emulator/SpdEmulator.cs @@ -112,10 +112,10 @@ private void DumpFile(string filepath, MultiStream stream) } /// - /// Invalidates a BF file with a specified name. + /// Invalidates a SPD file with a specified name. /// - /// Full path to the file. - public void UnregisterFile(string bfPath) => _pathToStream.Remove(bfPath, out _); + /// Full path to the file. + public void UnregisterFile(string spdPath) => _pathToStream.Remove(spdPath, out _); public void RegisterFile(string destinationPath, Stream stream) { diff --git a/Emulator/SPD.File.Emulator/SpdEmulatorApi.cs b/Emulator/SPD.File.Emulator/SpdEmulatorApi.cs index 8d251be..452e29c 100644 --- a/Emulator/SPD.File.Emulator/SpdEmulatorApi.cs +++ b/Emulator/SPD.File.Emulator/SpdEmulatorApi.cs @@ -1,9 +1,9 @@ using FileEmulationFramework.Interfaces; using FileEmulationFramework.Interfaces.Reference; using FileEmulationFramework.Lib.Utilities; -using Microsoft.Win32.SafeHandles; using SPD.File.Emulator.Interfaces; using SPD.File.Emulator.Interfaces.Structures.IO; +using SPD.File.Emulator.Utilities; using System.Runtime.InteropServices; namespace SPD.File.Emulator; @@ -96,10 +96,12 @@ public void RegisterSpd(string sourcePath, string destinationPath) _ = Native.SetFilePointerEx(handle, 0, IntPtr.Zero, 0); - var fileStream = new FileStream(new SafeFileHandle(handle, false), FileAccess.Read); + var fileStream = new FileStream(sourcePath, FileMode.Open); + var stream = StreamUtils.CreateMemoryStream(fileStream.Length); + fileStream.CopyTo(stream); - var emulated = new EmulatedFile(fileStream); - _spdEmulator.RegisterFile(destinationPath, fileStream); + var emulated = new EmulatedFile(stream); + _spdEmulator.RegisterFile(destinationPath, stream); _framework.RegisterVirtualFile(destinationPath, emulated); _logger.Info("[SpdEmulatorApi] Registered spd {0} at {1}", sourcePath, destinationPath);