主项目和VirtualNES.Core核心 NS下不再依赖system.io进行文件读写

This commit is contained in:
sin365 2025-04-24 16:34:09 +08:00
parent d7fe849bb1
commit 36b614c4a7
19 changed files with 125 additions and 129 deletions

View File

@ -5,7 +5,6 @@ using AxibugProtobuf;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
//using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using UnityEngine; using UnityEngine;
using static AxibugEmuOnline.Client.HttpAPI; using static AxibugEmuOnline.Client.HttpAPI;

View File

@ -1,10 +1,7 @@
using DG.Tweening.Plugins.Core.PathCore; using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using Unity.Android.Gradle.Manifest;
using UnityEngine; using UnityEngine;
using static UnityEngine.Analytics.IAnalytic;
namespace AxiIO namespace AxiIO
{ {

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
//using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;

View File

@ -11,7 +11,7 @@ using Essgee.Metadata;
using Essgee.Utilities; using Essgee.Utilities;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; //using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using UnityEngine; using UnityEngine;
@ -189,29 +189,29 @@ public class UEssgee : MonoBehaviour, IEmuCore
EmuStandInfo.ProductName = "AxibugEmu"; EmuStandInfo.ProductName = "AxibugEmu";
EmuStandInfo.ProductVersion = ""; EmuStandInfo.ProductVersion = "";
EmuStandInfo.programDataDirectory = Path.Combine(CustonDataDir, EmuStandInfo.ProductName); EmuStandInfo.programDataDirectory = System.IO.Path.Combine(CustonDataDir, EmuStandInfo.ProductName);
EmuStandInfo.programConfigPath = Path.Combine(EmuStandInfo.programDataDirectory, EmuStandInfo.jsonConfigFileName); EmuStandInfo.programConfigPath = System.IO.Path.Combine(EmuStandInfo.programDataDirectory, EmuStandInfo.jsonConfigFileName);
EmuStandInfo.ShaderPath = Path.Combine(CustonDataDir, "Assets", "Shaders"); EmuStandInfo.ShaderPath = System.IO.Path.Combine(CustonDataDir, "Assets", "Shaders");
EmuStandInfo.SaveDataPath = Path.Combine(EmuStandInfo.programDataDirectory, EmuStandInfo.saveDataDirectoryName); EmuStandInfo.SaveDataPath = System.IO.Path.Combine(EmuStandInfo.programDataDirectory, EmuStandInfo.saveDataDirectoryName);
EmuStandInfo.ScreenshotPath = Path.Combine(EmuStandInfo.programDataDirectory, EmuStandInfo.screenshotDirectoryName); EmuStandInfo.ScreenshotPath = System.IO.Path.Combine(EmuStandInfo.programDataDirectory, EmuStandInfo.screenshotDirectoryName);
EmuStandInfo.SaveStatePath = Path.Combine(EmuStandInfo.programDataDirectory, EmuStandInfo.saveStateDirectoryName); EmuStandInfo.SaveStatePath = System.IO.Path.Combine(EmuStandInfo.programDataDirectory, EmuStandInfo.saveStateDirectoryName);
EmuStandInfo.ExtraDataPath = Path.Combine(EmuStandInfo.programDataDirectory, EmuStandInfo.extraDataDirectoryName); EmuStandInfo.ExtraDataPath = System.IO.Path.Combine(EmuStandInfo.programDataDirectory, EmuStandInfo.extraDataDirectoryName);
LoadConfiguration(); LoadConfiguration();
if (!Directory.Exists(EmuStandInfo.SaveDataPath)) if (!AxiIO.Directory.Exists(EmuStandInfo.SaveDataPath))
Directory.CreateDirectory(EmuStandInfo.SaveDataPath); AxiIO.Directory.CreateDirectory(EmuStandInfo.SaveDataPath);
if (!Directory.Exists(EmuStandInfo.ScreenshotPath)) if (!AxiIO.Directory.Exists(EmuStandInfo.ScreenshotPath))
Directory.CreateDirectory(EmuStandInfo.ScreenshotPath); AxiIO.Directory.CreateDirectory(EmuStandInfo.ScreenshotPath);
if (!Directory.Exists(EmuStandInfo.SaveStatePath)) if (!AxiIO.Directory.Exists(EmuStandInfo.SaveStatePath))
Directory.CreateDirectory(EmuStandInfo.SaveStatePath); AxiIO.Directory.CreateDirectory(EmuStandInfo.SaveStatePath);
if (!Directory.Exists(EmuStandInfo.ExtraDataPath)) if (!AxiIO.Directory.Exists(EmuStandInfo.ExtraDataPath))
Directory.CreateDirectory(EmuStandInfo.ExtraDataPath); AxiIO.Directory.CreateDirectory(EmuStandInfo.ExtraDataPath);
if (AppEnvironment.EnableLogger) if (AppEnvironment.EnableLogger)
{ {
@ -756,13 +756,13 @@ public class UEssgee : MonoBehaviour, IEmuCore
} }
/* Generate filename/path */ /* Generate filename/path */
var filePrefix = $"{Path.GetFileNameWithoutExtension(lastGameMetadata.FileName)} ({e.Description}{(includeDateTime ? $" {DateTime.Now:yyyy-MM-dd HH-mm-ss})" : ")")}"; var filePrefix = $"{System.IO.Path.GetFileNameWithoutExtension(lastGameMetadata.FileName)} ({e.Description}{(includeDateTime ? $" {DateTime.Now:yyyy-MM-dd HH-mm-ss})" : ")")}";
var filePath = Path.Combine(EmuStandInfo.ExtraDataPath, $"{filePrefix}.{extension}"); var filePath = System.IO.Path.Combine(EmuStandInfo.ExtraDataPath, $"{filePrefix}.{extension}");
if (!allowOverwrite) if (!allowOverwrite)
{ {
var existingFiles = Directory.EnumerateFiles(EmuStandInfo.ExtraDataPath, $"{filePrefix}*{extension}"); var existingFiles = AxiIO.Directory.EnumerateFiles(EmuStandInfo.ExtraDataPath, $"{filePrefix}*{extension}");
if (existingFiles.Contains(filePath)) if (existingFiles.Contains(filePath))
for (int i = 2; existingFiles.Contains(filePath = Path.Combine(EmuStandInfo.ExtraDataPath, $"{filePrefix} ({i}).{extension}")); i++) { } for (int i = 2; existingFiles.Contains(filePath = System.IO.Path.Combine(EmuStandInfo.ExtraDataPath, $"{filePrefix} ({i}).{extension}")); i++) { }
} }
/* Handle data */ /* Handle data */
@ -777,10 +777,12 @@ public class UEssgee : MonoBehaviour, IEmuCore
else if (e.Data is byte[] raw) else if (e.Data is byte[] raw)
{ {
/* Raw bytes */ /* Raw bytes */
using (var file = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)) //using (var file = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
{ //{
file.Write(raw, 0, raw.Length); // file.Write(raw, 0, raw.Length);
} //}
AxiIO.File.WriteAllBytes(filePath, raw);
} }
} }

View File

@ -1,9 +1,6 @@
using AxibugEmuOnline.Client.ClientCore; using AxibugEmuOnline.Client.ClientCore;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using UnityEngine; using UnityEngine;
public class UEGSoundPlayer : MonoBehaviour public class UEGSoundPlayer : MonoBehaviour

View File

@ -5,7 +5,6 @@ using AxiReplay;
using MAME.Core; using MAME.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Text; using System.Text;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
@ -197,11 +196,11 @@ public class UMAME : MonoBehaviour, IEmuCore
} }
byte[] SaveState() byte[] SaveState()
{ {
if (!Directory.Exists(SavePath)) if (!AxiIO.Directory.Exists(SavePath))
Directory.CreateDirectory(SavePath); AxiIO.Directory.CreateDirectory(SavePath);
MemoryStream ms = new MemoryStream(); System.IO.MemoryStream ms = new System.IO.MemoryStream();
BinaryWriter bw = new BinaryWriter(ms); System.IO.BinaryWriter bw = new System.IO.BinaryWriter(ms);
emu.SaveState(bw); emu.SaveState(bw);
byte[] data = ms.ToArray(); byte[] data = ms.ToArray();
bw.Close(); bw.Close();
@ -218,8 +217,8 @@ public class UMAME : MonoBehaviour, IEmuCore
} }
void LoadState(byte[] data) void LoadState(byte[] data)
{ {
MemoryStream fs = new MemoryStream(data); System.IO.MemoryStream fs = new System.IO.MemoryStream(data);
BinaryReader br = new BinaryReader(fs); System.IO.BinaryReader br = new System.IO.BinaryReader(fs);
emu.LoadState(br); emu.LoadState(br);
br.Close(); br.Close();
fs.Close(); fs.Close();

View File

@ -2,7 +2,6 @@
using AxibugProtobuf; using AxibugProtobuf;
using AxiReplay; using AxiReplay;
using System; using System;
using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using UnityEngine; using UnityEngine;
using VirtualNes.Core; using VirtualNes.Core;
@ -17,14 +16,14 @@ namespace AxibugEmuOnline.Client
m_controllerMapper = conMapper; m_controllerMapper = conMapper;
} }
public Stream OpenRom(string fname) public System.IO.Stream OpenRom(string fname)
{ {
try try
{ {
var romFile = App.GetRomLib(RomPlatformType.Nes).GetRomFile(fname); var romFile = App.GetRomLib(RomPlatformType.Nes).GetRomFile(fname);
var bytes = romFile.GetRomFileData(); var bytes = romFile.GetRomFileData();
Debug.Log($"Open {romFile.Alias}"); Debug.Log($"Open {romFile.Alias}");
return new MemoryStream(bytes); return new System.IO.MemoryStream(bytes);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -39,34 +38,34 @@ namespace AxibugEmuOnline.Client
UnityEngine.Debug.Assert(romFile != null); UnityEngine.Debug.Assert(romFile != null);
fullPath = romFile.LocalFilePath; fullPath = romFile.LocalFilePath;
directPath = Path.GetDirectoryName(fullPath); directPath = System.IO.Path.GetDirectoryName(fullPath);
} }
public Stream OpenFile_DISKSYS() public System.IO.Stream OpenFile_DISKSYS()
{ {
return new MemoryStream(Resources.Load<TextAsset>("NES/Disksys.rom").bytes); return new System.IO.MemoryStream(Resources.Load<TextAsset>("NES/Disksys.rom").bytes);
} }
public void SaveSRAMToFile(byte[] sramContent, string romName) public void SaveSRAMToFile(byte[] sramContent, string romName)
{ {
string sramDirectoryPath = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{Config.path.szSavePath}"; string sramDirectoryPath = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{Config.path.szSavePath}";
Directory.CreateDirectory(sramDirectoryPath); AxiIO.Directory.CreateDirectory(sramDirectoryPath);
romName = Path.GetFileNameWithoutExtension(romName); romName = System.IO.Path.GetFileNameWithoutExtension(romName);
File.WriteAllBytes($"{sramDirectoryPath}/{romName}.sav", sramContent); AxiIO.File.WriteAllBytes($"{sramDirectoryPath}/{romName}.sav", sramContent);
} }
public void SaveDISKToFile(byte[] diskFileContent, string romName) public void SaveDISKToFile(byte[] diskFileContent, string romName)
{ {
string diskFileDirectoryPath = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/dsv"; string diskFileDirectoryPath = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/dsv";
Directory.CreateDirectory(diskFileDirectoryPath); AxiIO.Directory.CreateDirectory(diskFileDirectoryPath);
romName = Path.GetFileNameWithoutExtension(romName); romName = System.IO.Path.GetFileNameWithoutExtension(romName);
File.WriteAllBytes($"{diskFileDirectoryPath}/{romName}.dsv", diskFileContent); AxiIO.File.WriteAllBytes($"{diskFileDirectoryPath}/{romName}.dsv", diskFileContent);
} }
public EmulatorConfig Config { get; private set; } = new EmulatorConfig(); public EmulatorConfig Config { get; private set; } = new EmulatorConfig();
public void PrepareDirectory(string directPath) public void PrepareDirectory(string directPath)
{ {
Directory.CreateDirectory($"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{directPath}"); AxiIO.Directory.CreateDirectory($"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{directPath}");
} }
public void SaveFile(byte[] fileData, string directPath, string fileName) public void SaveFile(byte[] fileData, string directPath, string fileName)
@ -74,17 +73,17 @@ namespace AxibugEmuOnline.Client
PrepareDirectory(directPath); PrepareDirectory(directPath);
var fileFullpath = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{directPath}/{fileName}"; var fileFullpath = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{directPath}/{fileName}";
File.WriteAllBytes(fileFullpath, fileData); AxiIO.File.WriteAllBytes(fileFullpath, fileData);
} }
public Stream OpenFile(string directPath, string fileName) public System.IO.Stream OpenFile(string directPath, string fileName)
{ {
try try
{ {
var path = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{directPath}/{fileName}"; var path = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{directPath}/{fileName}";
var data = File.ReadAllBytes(path); var data = AxiIO.File.ReadAllBytes(path);
if (data == null) return null; if (data == null) return null;
return new MemoryStream(data); return new System.IO.MemoryStream(data);
} }
catch catch
{ {

View File

@ -3,7 +3,6 @@ using AxibugProtobuf;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.IO;
using System.Xml.Linq; using System.Xml.Linq;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
@ -178,7 +177,7 @@ namespace AxibugEmuOnline.Client
var db = Resources.Load<RomDB>("NES/ROMDB"); var db = Resources.Load<RomDB>("NES/ROMDB");
db.Clear(); db.Clear();
var xmlStr = File.ReadAllText("nes20db.xml"); var xmlStr = System.IO.File.ReadAllText("nes20db.xml");
var xml = XDocument.Parse(xmlStr); var xml = XDocument.Parse(xmlStr);
var games = xml.Element("nes20db")?.Elements("game"); var games = xml.Element("nes20db")?.Elements("game");
System.Diagnostics.Debug.Assert(games != null, nameof(games) + " != null"); System.Diagnostics.Debug.Assert(games != null, nameof(games) + " != null");

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Xml; using System.Xml;
using System.Xml.Serialization; using System.Xml.Serialization;
@ -16,24 +15,24 @@ public sealed class DatabaseHandler
{ {
string wsc = "Bandai - WonderSwan Color.dat"; string wsc = "Bandai - WonderSwan Color.dat";
GetDatBytes(wsc, out byte[] loadedData); GetDatBytes(wsc, out byte[] loadedData);
using (MemoryStream stream = new MemoryStream(loadedData)) using (System.IO.MemoryStream stream = new System.IO.MemoryStream(loadedData))
{ {
var root = new XmlRootAttribute("datafile") { IsNullable = true }; var root = new XmlRootAttribute("datafile") { IsNullable = true };
var serializer = new XmlSerializer(typeof(DatFile), root); var serializer = new XmlSerializer(typeof(DatFile), root);
var reader = XmlReader.Create(stream, new() { DtdProcessing = DtdProcessing.Ignore }); var reader = XmlReader.Create(stream, new() { DtdProcessing = DtdProcessing.Ignore });
datFiles.Add(Path.GetFileName(wsc), (DatFile)serializer.Deserialize(reader)); datFiles.Add(System.IO.Path.GetFileName(wsc), (DatFile)serializer.Deserialize(reader));
} }
} }
{ {
string ws = "Bandai - WonderSwan.dat"; string ws = "Bandai - WonderSwan.dat";
GetDatBytes(ws, out byte[] loadedData); GetDatBytes(ws, out byte[] loadedData);
using (MemoryStream stream = new MemoryStream(loadedData)) using (System.IO.MemoryStream stream = new System.IO.MemoryStream(loadedData))
{ {
var root = new XmlRootAttribute("datafile") { IsNullable = true }; var root = new XmlRootAttribute("datafile") { IsNullable = true };
var serializer = new XmlSerializer(typeof(DatFile), root); var serializer = new XmlSerializer(typeof(DatFile), root);
var reader = XmlReader.Create(stream, new() { DtdProcessing = DtdProcessing.Ignore }); var reader = XmlReader.Create(stream, new() { DtdProcessing = DtdProcessing.Ignore });
datFiles.Add(Path.GetFileName(ws), (DatFile)serializer.Deserialize(reader)); datFiles.Add(System.IO.Path.GetFileName(ws), (DatFile)serializer.Deserialize(reader));
} }
} }

View File

@ -5,7 +5,6 @@ using StoicGoose.Common.Utilities;
using StoicGoose.Core.Machines; using StoicGoose.Core.Machines;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
@ -22,7 +21,7 @@ public class UStoicGoose : MonoBehaviour, IEmuCore
readonly static int maxRecentFiles = 15; readonly static int maxRecentFiles = 15;
readonly static int statusIconSize = 12; readonly static int statusIconSize = 12;
readonly static List<(string description, string extension, Func<string, Stream> streamReadFunc)> supportedFileInformation = new() readonly static List<(string description, string extension, Func<string, System.IO.Stream> streamReadFunc)> supportedFileInformation = new()
{ {
("WonderSwan ROMs", ".ws", GetStreamFromFile), ("WonderSwan ROMs", ".ws", GetStreamFromFile),
("WonderSwan Color ROMs", ".wsc", GetStreamFromFile), ("WonderSwan Color ROMs", ".wsc", GetStreamFromFile),
@ -312,7 +311,7 @@ public class UStoicGoose : MonoBehaviour, IEmuCore
// graphicsHandler.DrawFrame(); // graphicsHandler.DrawFrame();
//}; //};
internalEepromPath = Path.Combine(Program.InternalDataPath, $"{machineType.Name}.eep"); internalEepromPath = System.IO.Path.Combine(Program.InternalDataPath, $"{machineType.Name}.eep");
} }
//private void InitializeWindows() //private void InitializeWindows()
@ -408,11 +407,14 @@ public class UStoicGoose : MonoBehaviour, IEmuCore
if (!emulatorHandler.IsRunning) if (!emulatorHandler.IsRunning)
{ {
if (File.Exists(filename)) if (AxiIO.File.Exists(filename))
{ {
using var stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); //using var stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
var data = new byte[stream.Length]; //var data = new byte[stream.Length];
stream.Read(data, 0, data.Length); //stream.Read(data, 0, data.Length);
var data = AxiIO.File.ReadAllBytes(filename);
emulatorHandler.Machine.LoadBootstrap(data); emulatorHandler.Machine.LoadBootstrap(data);
} }
emulatorHandler.Machine.UseBootstrap = Program.Configuration.General.UseBootstrap; emulatorHandler.Machine.UseBootstrap = Program.Configuration.General.UseBootstrap;
@ -421,23 +423,31 @@ public class UStoicGoose : MonoBehaviour, IEmuCore
private void LoadInternalEeprom() private void LoadInternalEeprom()
{ {
if (!emulatorHandler.IsRunning && File.Exists(internalEepromPath)) if (!emulatorHandler.IsRunning && AxiIO.File.Exists(internalEepromPath))
{ {
using var stream = new FileStream(internalEepromPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); //using var stream = new FileStream(internalEepromPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
var data = new byte[stream.Length]; //var data = new byte[stream.Length];
stream.Read(data, 0, data.Length); //stream.Read(data, 0, data.Length);
var data = AxiIO.File.ReadAllBytes(internalEepromPath);
emulatorHandler.Machine.LoadInternalEeprom(data); emulatorHandler.Machine.LoadInternalEeprom(data);
} }
} }
private static Stream GetStreamFromFile(string filename) private static System.IO.Stream GetStreamFromFile(string filename)
{ {
return new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); //return new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
byte[] data = AxiIO.File.ReadAllBytes(filename);
return new System.IO.MemoryStream(data);
} }
private static Stream GetStreamFromFirstZippedFile(string filename) private static System.IO.Stream GetStreamFromFirstZippedFile(string filename)
{ {
return new ZipArchive(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)).Entries.FirstOrDefault()?.Open(); //return new ZipArchive(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)).Entries.FirstOrDefault()?.Open();
byte[] data = AxiIO.File.ReadAllBytes(filename);
return new ZipArchive(new System.IO.MemoryStream(data)).Entries.FirstOrDefault()?.Open();
} }
private bool LoadAndRunCartridge(string filename) private bool LoadAndRunCartridge(string filename)
@ -450,8 +460,8 @@ public class UStoicGoose : MonoBehaviour, IEmuCore
emulatorHandler.Shutdown(); emulatorHandler.Shutdown();
} }
using var inputStream = supportedFileInformation.FirstOrDefault(x => x.extension == Path.GetExtension(filename)).streamReadFunc(filename) ?? GetStreamFromFile(filename); using var inputStream = supportedFileInformation.FirstOrDefault(x => x.extension == System.IO.Path.GetExtension(filename)).streamReadFunc(filename) ?? GetStreamFromFile(filename);
using var stream = new MemoryStream(); using var stream = new System.IO.MemoryStream();
inputStream.CopyTo(stream); inputStream.CopyTo(stream);
stream.Position = 0; stream.Position = 0;
@ -462,7 +472,7 @@ public class UStoicGoose : MonoBehaviour, IEmuCore
graphicsHandler.IsVerticalOrientation = isVerticalOrientation = emulatorHandler.Machine.Cartridge.Metadata.Orientation == CartridgeMetadata.Orientations.Vertical; graphicsHandler.IsVerticalOrientation = isVerticalOrientation = emulatorHandler.Machine.Cartridge.Metadata.Orientation == CartridgeMetadata.Orientations.Vertical;
inputHandler.SetVerticalOrientation(isVerticalOrientation); inputHandler.SetVerticalOrientation(isVerticalOrientation);
CurrRomName = Path.GetFileName(filename); CurrRomName = System.IO.Path.GetFileName(filename);
LoadRam(); LoadRam();
@ -490,12 +500,15 @@ public class UStoicGoose : MonoBehaviour, IEmuCore
private void LoadRam() private void LoadRam()
{ {
//var path = Path.Combine(Program.SaveDataPath, $"{Path.GetFileNameWithoutExtension(Program.Configuration.General.RecentFiles.First())}.sav"); //var path = Path.Combine(Program.SaveDataPath, $"{Path.GetFileNameWithoutExtension(Program.Configuration.General.RecentFiles.First())}.sav");
var path = Path.Combine(Program.SaveDataPath, $"{CurrRomName}.sav"); var path = System.IO.Path.Combine(Program.SaveDataPath, $"{CurrRomName}.sav");
if (!File.Exists(path)) return; //if (!File.Exists(path)) return;
if (!AxiIO.File.Exists(path)) return;
using var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); //using var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
var data = new byte[stream.Length]; //var data = new byte[stream.Length];
stream.Read(data, 0, data.Length); //stream.Read(data, 0, data.Length);
var data = AxiIO.File.ReadAllBytes(path);
if (data.Length != 0) if (data.Length != 0)
emulatorHandler.Machine.LoadSaveData(data); emulatorHandler.Machine.LoadSaveData(data);
} }
@ -511,8 +524,10 @@ public class UStoicGoose : MonoBehaviour, IEmuCore
var data = emulatorHandler.Machine.GetInternalEeprom(); var data = emulatorHandler.Machine.GetInternalEeprom();
if (data.Length == 0) return; if (data.Length == 0) return;
using var stream = new FileStream(internalEepromPath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite); //using var stream = new FileStream(internalEepromPath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
stream.Write(data, 0, data.Length); //stream.Write(data, 0, data.Length);
AxiIO.File.WriteAllBytes(internalEepromPath, data);
} }
private void SaveRam() private void SaveRam()
@ -521,10 +536,12 @@ public class UStoicGoose : MonoBehaviour, IEmuCore
if (data.Length == 0) return; if (data.Length == 0) return;
//var path = Path.Combine(Program.SaveDataPath, $"{Path.GetFileNameWithoutExtension(Program.Configuration.General.RecentFiles.First())}.sav"); //var path = Path.Combine(Program.SaveDataPath, $"{Path.GetFileNameWithoutExtension(Program.Configuration.General.RecentFiles.First())}.sav");
var path = Path.Combine(Program.SaveDataPath, $"{CurrRomName}.sav"); var path = System.IO.Path.Combine(Program.SaveDataPath, $"{CurrRomName}.sav");
using var stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite); //using var stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
stream.Write(data, 0, data.Length); //stream.Write(data, 0, data.Length);
AxiIO.File.WriteAllBytes(path, data);
} }
@ -603,25 +620,25 @@ static class Program
shaderDirectoryName = "Shaders"; shaderDirectoryName = "Shaders";
noIntroDatDirectoryName = "No-Intro"; noIntroDatDirectoryName = "No-Intro";
mutexName = $"Unity_{GetVersionDetails()}"; mutexName = $"Unity_{GetVersionDetails()}";
programDataDirectory = Path.Combine(CustonDataDir, "AxibugEmu"); programDataDirectory = System.IO.Path.Combine(CustonDataDir, "AxibugEmu");
programConfigPath = Path.Combine(programDataDirectory, jsonConfigFileName); programConfigPath = System.IO.Path.Combine(programDataDirectory, jsonConfigFileName);
Configuration = LoadConfiguration(programConfigPath); Configuration = LoadConfiguration(programConfigPath);
Log.WriteLine(Path.Combine(programDataDirectory, logFileName)); Log.WriteLine(System.IO.Path.Combine(programDataDirectory, logFileName));
programApplicationDirectory = AppDomain.CurrentDomain.BaseDirectory; programApplicationDirectory = AppDomain.CurrentDomain.BaseDirectory;
programAssetsDirectory = Path.Combine(programApplicationDirectory, assetsDirectoryName); programAssetsDirectory = System.IO.Path.Combine(programApplicationDirectory, assetsDirectoryName);
Directory.CreateDirectory(DataPath = programDataDirectory); AxiIO.Directory.CreateDirectory(DataPath = programDataDirectory);
Directory.CreateDirectory(InternalDataPath = Path.Combine(programDataDirectory, internalDataDirectoryName)); AxiIO.Directory.CreateDirectory(InternalDataPath = System.IO.Path.Combine(programDataDirectory, internalDataDirectoryName));
Directory.CreateDirectory(SaveDataPath = Path.Combine(programDataDirectory, saveDataDirectoryName)); AxiIO.Directory.CreateDirectory(SaveDataPath = System.IO.Path.Combine(programDataDirectory, saveDataDirectoryName));
Directory.CreateDirectory(CheatsDataPath = Path.Combine(programDataDirectory, cheatDataDirectoryName)); AxiIO.Directory.CreateDirectory(CheatsDataPath = System.IO.Path.Combine(programDataDirectory, cheatDataDirectoryName));
Directory.CreateDirectory(DebuggingDataPath = Path.Combine(programDataDirectory, debuggingDataDirectoryName)); AxiIO.Directory.CreateDirectory(DebuggingDataPath = System.IO.Path.Combine(programDataDirectory, debuggingDataDirectoryName));
//if (!Directory.Exists(ShaderPath = Path.Combine(programAssetsDirectory, shaderDirectoryName))) //if (!Directory.Exists(ShaderPath = Path.Combine(programAssetsDirectory, shaderDirectoryName)))
// throw new DirectoryNotFoundException("Shader directory missing"); // throw new DirectoryNotFoundException("Shader directory missing");
if (!Directory.Exists(NoIntroDatPath = Path.Combine(programAssetsDirectory, noIntroDatDirectoryName))) if (!AxiIO.Directory.Exists(NoIntroDatPath = System.IO.Path.Combine(programAssetsDirectory, noIntroDatDirectoryName)))
throw new DirectoryNotFoundException("No-Intro .dat directory missing"); throw new Exception("No-Intro .dat directory missing");
} }
catch (DirectoryNotFoundException e) catch (Exception e)
{ {
} }
} }
@ -674,7 +691,7 @@ static class Program
private static Configuration LoadConfiguration(string filename) private static Configuration LoadConfiguration(string filename)
{ {
Directory.CreateDirectory(Path.GetDirectoryName(filename)); AxiIO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(filename));
Configuration configuration; Configuration configuration;
//if (!File.Exists(filename) || (configuration = filename.DeserializeFromFile<Configuration>()) == null) //if (!File.Exists(filename) || (configuration = filename.DeserializeFromFile<Configuration>()) == null)

View File

@ -2,7 +2,6 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
//using System.IO;
using UnityEngine; using UnityEngine;
namespace AxibugEmuOnline.Client namespace AxibugEmuOnline.Client

View File

@ -5,7 +5,6 @@ using ICSharpCode.SharpZipLib.Zip;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
//using System.IO;
using UnityEngine; using UnityEngine;
namespace AxibugEmuOnline.Client namespace AxibugEmuOnline.Client

View File

@ -4,7 +4,6 @@ using AxibugEmuOnline.Client.Event;
using AxibugProtobuf; using AxibugProtobuf;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
//using System.IO;
using System.Linq; using System.Linq;
using static AxibugEmuOnline.Client.HttpAPI; using static AxibugEmuOnline.Client.HttpAPI;

View File

@ -2,8 +2,6 @@
using AxibugEmuOnline.Client.Tools; using AxibugEmuOnline.Client.Tools;
using AxibugProtobuf; using AxibugProtobuf;
using System; using System;
//using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace AxibugEmuOnline.Client namespace AxibugEmuOnline.Client

View File

@ -1,7 +1,6 @@
using AxibugEmuOnline.Client.ClientCore; using AxibugEmuOnline.Client.ClientCore;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
//using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using UnityEngine; using UnityEngine;

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Text; using System.Text;
using VirtualNes.Core.Debug; using VirtualNes.Core.Debug;
@ -28,13 +27,13 @@ namespace VirtualNes.Core
private int m_nNsfSongMode; private int m_nNsfSongMode;
private bool m_bMoviePlay; private bool m_bMoviePlay;
private bool m_bMovieRec; private bool m_bMovieRec;
private Stream m_fpMovie; private System.IO.Stream m_fpMovie;
private uint m_MovieControl; private uint m_MovieControl;
private int m_MovieStepTotal; private int m_MovieStepTotal;
private int m_MovieStep; private int m_MovieStep;
private bool m_bTapePlay; private bool m_bTapePlay;
private bool m_bTapeRec; private bool m_bTapeRec;
private Stream m_fpTape; private System.IO.Stream m_fpTape;
private double m_TapeCycles; private double m_TapeCycles;
private byte m_TapeIn; private byte m_TapeIn;
private byte m_TapeOut; private byte m_TapeOut;
@ -1110,7 +1109,7 @@ namespace VirtualNes.Core
return; return;
int i = 0; int i = 0;
Stream fp = null; System.IO.Stream fp = null;
DISKFILEHDR ifh; DISKFILEHDR ifh;
byte[] lpDisk = rom.GetPROM(); byte[] lpDisk = rom.GetPROM();
byte[] lpWrite = rom.GetDISK(); byte[] lpWrite = rom.GetDISK();

View File

@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using VirtualNes.Core.Debug; using VirtualNes.Core.Debug;
namespace VirtualNes.Core namespace VirtualNes.Core
@ -29,7 +28,7 @@ namespace VirtualNes.Core
public ROM(string fname) public ROM(string fname)
{ {
Stream fp = null; System.IO.Stream fp = null;
byte[] temp = null; byte[] temp = null;
byte[] bios = null; byte[] bios = null;
long FileSize = 0; long FileSize = 0;
@ -218,7 +217,7 @@ namespace VirtualNes.Core
} }
Supporter.S.GetRomPathInfo(fname, out fullpath, out path); Supporter.S.GetRomPathInfo(fname, out fullpath, out path);
name = Path.GetFileNameWithoutExtension(fullpath); name = System.IO.Path.GetFileNameWithoutExtension(fullpath);
if (!bNSF) if (!bNSF)
{ {
mapper = (header.control1 >> 4) | (header.control2 & 0xF0); mapper = (header.control1 >> 4) | (header.control2 & 0xF0);

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Text; using System.Text;
namespace VirtualNes.Core namespace VirtualNes.Core
@ -84,22 +83,22 @@ namespace VirtualNes.Core
} }
public class StateReader public class StateReader
{ {
private MemoryStream m_dataStream; private System.IO.MemoryStream m_dataStream;
public long Remain => m_dataStream.Length - 1 - m_dataStream.Position; public long Remain => m_dataStream.Length - 1 - m_dataStream.Position;
public StateReader(byte[] bytes) public StateReader(byte[] bytes)
{ {
m_dataStream = new MemoryStream(bytes); m_dataStream = new System.IO.MemoryStream(bytes);
} }
public void Skip(uint count) public void Skip(uint count)
{ {
m_dataStream.Seek(count, SeekOrigin.Current); m_dataStream.Seek(count, System.IO.SeekOrigin.Current);
} }
public void Skip(long count) public void Skip(long count)
{ {
m_dataStream.Seek(count, SeekOrigin.Current); m_dataStream.Seek(count, System.IO.SeekOrigin.Current);
} }
public byte[] Read_bytes(int length) public byte[] Read_bytes(int length)

View File

@ -1,6 +1,4 @@
using System.IO; namespace VirtualNes.Core
namespace VirtualNes.Core
{ {
public static class Supporter public static class Supporter
{ {
@ -15,15 +13,15 @@ namespace VirtualNes.Core
public interface ISupporterImpl public interface ISupporterImpl
{ {
Stream OpenRom(string fname); System.IO.Stream OpenRom(string fname);
void GetRomPathInfo(string fname, out string fullPath, out string directPath); void GetRomPathInfo(string fname, out string fullPath, out string directPath);
Stream OpenFile_DISKSYS(); System.IO.Stream OpenFile_DISKSYS();
void SaveSRAMToFile(byte[] sramContent, string romName); void SaveSRAMToFile(byte[] sramContent, string romName);
void SaveDISKToFile(byte[] diskFileContent, string romName); void SaveDISKToFile(byte[] diskFileContent, string romName);
EmulatorConfig Config { get; } EmulatorConfig Config { get; }
void PrepareDirectory(string directPath); void PrepareDirectory(string directPath);
void SaveFile(byte[] fileData, string directPath, string fileName); void SaveFile(byte[] fileData, string directPath, string fileName);
Stream OpenFile(string directPath, string fileName); System.IO.Stream OpenFile(string directPath, string fileName);
bool TryGetMapperNo(ROM rom, out int mapperNo); bool TryGetMapperNo(ROM rom, out int mapperNo);
ControllerState GetControllerState(); ControllerState GetControllerState();
void SampleInput(uint frameCount); void SampleInput(uint frameCount);