除了核心之外的,已经包装了区分Switch和普通的IO
This commit is contained in:
parent
ee9d54386b
commit
d7fe849bb1
@ -3,7 +3,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEditor;
|
||||
@ -20,7 +19,17 @@ namespace AxibugEmuOnline.Editors
|
||||
static Dictionary<string, string> tools = new Dictionary<string, string>();
|
||||
static string prodKeysPath;
|
||||
|
||||
[MenuItem("Axibug盧濂묏야/Switch/AxibugNSPTools/RepackNSP(쏭路劤뭐쉔NPS)")]
|
||||
static void InitToolPath()
|
||||
{
|
||||
#region 初始化工具路径
|
||||
// 获取环境变量(需要添加环境变量检查)
|
||||
string sdkRoot = Environment.GetEnvironmentVariable("NINTENDO_SDK_ROOT");
|
||||
tools["authoringTool"] = Path.Combine(sdkRoot, "Tools/CommandLineTools/AuthoringTool/AuthoringTool.exe");
|
||||
tools["hacPack"] = Path.Combine(hacpack_root, "hacpack");
|
||||
#endregion
|
||||
}
|
||||
|
||||
[MenuItem("Axibug移植工具/Switch/AxibugNSPTools/RepackNSP(仅重新构建NSP)")]
|
||||
static void RepackNSP()
|
||||
{
|
||||
if (!CheckEnvironmentVariable())
|
||||
@ -38,7 +47,29 @@ namespace AxibugEmuOnline.Editors
|
||||
RepackNSP(path);
|
||||
}
|
||||
|
||||
[MenuItem("Axibug盧濂묏야/Switch/AxibugNSPTools/Build With RepackNSP(댔관NSP깻路劤뭐쉔NPS)")]
|
||||
|
||||
//[MenuItem("Axibug移植工具/Switch/AxibugNSPTools/UnpackNSP(解包工具)")]
|
||||
//static void UnpackNSP()
|
||||
//{
|
||||
// InitToolPath();
|
||||
// if (!CheckEnvironmentVariable())
|
||||
// return;
|
||||
|
||||
// string nspFilePath = EditorUtility.OpenFilePanel(
|
||||
// title: "选择 .nsp 文件",
|
||||
// directory: Path.Combine(Application.dataPath, ".."), // 默认路径为项目 Assets 目录
|
||||
// extension: "nsp" // 限制文件类型为 .nsp
|
||||
// );
|
||||
|
||||
// if (string.IsNullOrEmpty(nspFilePath))
|
||||
// return;
|
||||
|
||||
// string nspParentDir = Path.GetDirectoryName(nspFilePath);
|
||||
// string extractPath = Path.Combine(nspParentDir, "repacker_extract");
|
||||
// ExecuteCommand($"{tools["authoringTool"]} extract -o \"{extractPath}\" \"{nspFilePath}\"", nspParentDir);
|
||||
//}
|
||||
|
||||
[MenuItem("Axibug移植工具/Switch/AxibugNSPTools/Build With RepackNSP(打包NSP并重新构建NSP)")]
|
||||
public static void BuildWithRepackNSP()
|
||||
{
|
||||
if (!CheckEnvironmentVariable())
|
||||
@ -121,12 +152,7 @@ namespace AxibugEmuOnline.Editors
|
||||
|
||||
static void RepackNSP(string nspFile)
|
||||
{
|
||||
#region 놓迦뺏묏야쨌쓺
|
||||
// 삿혤뻔쓱긴좆(矜狼警속뻔쓱긴좆쇱꿴)
|
||||
string sdkRoot = Environment.GetEnvironmentVariable("NINTENDO_SDK_ROOT");
|
||||
tools["authoringTool"] = Path.Combine(sdkRoot, "Tools/CommandLineTools/AuthoringTool/AuthoringTool.exe");
|
||||
tools["hacPack"] = Path.Combine(hacpack_root, "hacpack");
|
||||
#endregion
|
||||
InitToolPath();
|
||||
|
||||
#region ´¦ÀíNSPÎļþ·¾¶
|
||||
string nspFilePath = nspFile;
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "AxiNSApi"
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c8ad600c72d635843bd8aeb9d8aebfb8
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -62,6 +62,8 @@ public class AxiNSIO
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 保存并创建文件(如果目录不存在回先自动创建目录)
|
||||
/// </summary>
|
||||
@ -208,7 +210,13 @@ public class AxiNSIO
|
||||
AxiNS.instance.wait.AddWait(wait);
|
||||
return wait;
|
||||
}
|
||||
public bool LoadSwitchDataFile(string filename, ref System.IO.MemoryStream ms)
|
||||
public byte[] LoadSwitchDataFile(string filename)
|
||||
{
|
||||
LoadSwitchDataFile(filename, out byte[] outputData);
|
||||
return outputData;
|
||||
}
|
||||
|
||||
public bool LoadSwitchDataFile(string filename, ref System.IO.MemoryStream ms)
|
||||
{
|
||||
if (LoadSwitchDataFile(filename, out byte[] outputData))
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,7 @@ using AxibugProtobuf;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
//using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using static AxibugEmuOnline.Client.HttpAPI;
|
||||
@ -130,8 +130,10 @@ namespace AxibugEmuOnline.Client.ClientCore
|
||||
private static void PSP2Init()
|
||||
{
|
||||
//PSVita最好手动创建目录
|
||||
if (!Directory.Exists("ux0:data/AxibugEmu"))
|
||||
Directory.CreateDirectory("ux0:data/AxibugEmu");
|
||||
if (!AxiIO.Directory.Exists("ux0:data/AxibugEmu"))
|
||||
AxiIO.Directory.CreateDirectory("ux0:data/AxibugEmu");
|
||||
//if (!Directory.Exists("ux0:data/AxibugEmu"))
|
||||
// Directory.CreateDirectory("ux0:data/AxibugEmu");
|
||||
|
||||
#if UNITY_PSP2
|
||||
//创建PSV弹窗UI
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.IO.Compression;
|
||||
using System.Net;
|
||||
using System.Net.Security;
|
||||
using System.Net.Sockets;
|
||||
@ -162,7 +161,7 @@ public static class AxiHttp
|
||||
public string fileName;
|
||||
public float DownLoadPr =>
|
||||
NeedloadedLenght <= 0 ? -1 : (float)loadedLenght / NeedloadedLenght;
|
||||
public BinaryWriter binaryWriter;
|
||||
public System.IO.BinaryWriter binaryWriter;
|
||||
}
|
||||
|
||||
public static IPAddress GetDnsIP(string str)
|
||||
@ -268,7 +267,7 @@ public static class AxiHttp
|
||||
var ipEndPoint = new IPEndPoint(ip, port);
|
||||
|
||||
using (Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
using (MemoryStream memoryStream = new MemoryStream())
|
||||
using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream())
|
||||
{
|
||||
client.Connect(ipEndPoint);
|
||||
if (!client.Connected)
|
||||
@ -497,7 +496,7 @@ public static class AxiHttp
|
||||
|
||||
// 使用Uri类解析URL
|
||||
Uri uri = new Uri(url);
|
||||
respinfo.fileName = Path.GetFileName(uri.LocalPath);
|
||||
respinfo.fileName = System.IO.Path.GetFileName(uri.LocalPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -567,7 +566,7 @@ public static class AxiHttp
|
||||
|
||||
//using (Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
//using (TcpClient tcpclient = new TcpClient())
|
||||
using (MemoryStream memoryStream = new MemoryStream())
|
||||
using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream())
|
||||
{
|
||||
//client.Connect(ipEndPoint);
|
||||
|
||||
@ -780,7 +779,7 @@ public static class AxiHttp
|
||||
|
||||
// 使用Uri类解析URL
|
||||
Uri uri = new Uri(url);
|
||||
respinfo.fileName = Path.GetFileName(uri.LocalPath);
|
||||
respinfo.fileName = System.IO.Path.GetFileName(uri.LocalPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -865,9 +864,9 @@ public static class AxiHttp
|
||||
{
|
||||
|
||||
string str = "";
|
||||
MemoryStream ms = new MemoryStream(data, 0, len);
|
||||
System.IO.MemoryStream ms = new System.IO.MemoryStream(data, 0, len);
|
||||
GZipStream gs = new GZipStream(ms, CompressionMode.Decompress);
|
||||
MemoryStream outbuf = new MemoryStream();
|
||||
System.IO.MemoryStream outbuf = new System.IO.MemoryStream();
|
||||
byte[] block = new byte[1024];
|
||||
|
||||
try
|
||||
@ -904,9 +903,9 @@ public static class AxiHttp
|
||||
|
||||
public static byte[] unGzipBytes(byte[] data, int len)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream(data, 0, len);
|
||||
System.IO.MemoryStream ms = new System.IO.MemoryStream(data, 0, len);
|
||||
GZipStream gs = new GZipStream(ms, CompressionMode.Decompress);
|
||||
MemoryStream outbuf = new MemoryStream();
|
||||
System.IO.MemoryStream outbuf = new System.IO.MemoryStream();
|
||||
byte[] block = new byte[1024];
|
||||
byte[] result;
|
||||
try
|
||||
|
||||
8
AxibugEmuOnline.Client/Assets/Script/AppMain/AxiIO.meta
Normal file
8
AxibugEmuOnline.Client/Assets/Script/AppMain/AxiIO.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83041af3f896cdd428dd120d39becacf
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
190
AxibugEmuOnline.Client/Assets/Script/AppMain/AxiIO/AxiIO.cs
Normal file
190
AxibugEmuOnline.Client/Assets/Script/AppMain/AxiIO/AxiIO.cs
Normal file
@ -0,0 +1,190 @@
|
||||
using DG.Tweening.Plugins.Core.PathCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Unity.Android.Gradle.Manifest;
|
||||
using UnityEngine;
|
||||
using static UnityEngine.Analytics.IAnalytic;
|
||||
|
||||
namespace AxiIO
|
||||
{
|
||||
public interface IAxiIO
|
||||
{
|
||||
bool dir_Exists(string dirpath);
|
||||
void dir_CreateDirectory(string dirpath);
|
||||
IEnumerable<string> dir_EnumerateFiles(string path, string searchPattern);
|
||||
void dir_Delete(string path, bool recursive);
|
||||
byte[] file_ReadAllBytes(string filePath);
|
||||
bool file_Exists(string filePath);
|
||||
void file_Delete(string filePath);
|
||||
void file_WriteAllBytes(string filePath, byte[] data);
|
||||
void file_WriteAllBytes(string filePath, System.IO.MemoryStream ms);
|
||||
};
|
||||
|
||||
public class CSharpIO : IAxiIO
|
||||
{
|
||||
public void dir_CreateDirectory(string dirpath)
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(dirpath);
|
||||
}
|
||||
|
||||
public void dir_Delete(string path, bool recursive)
|
||||
{
|
||||
System.IO.Directory.Delete(path, recursive);
|
||||
}
|
||||
|
||||
public IEnumerable<string> dir_EnumerateFiles(string path, string searchPattern)
|
||||
{
|
||||
return System.IO.Directory.EnumerateFiles(path, searchPattern);
|
||||
}
|
||||
|
||||
public bool dir_Exists(string dirpath)
|
||||
{
|
||||
return System.IO.Directory.Exists(dirpath);
|
||||
}
|
||||
|
||||
public void file_WriteAllBytes(string filePath, byte[] data)
|
||||
{
|
||||
System.IO.File.WriteAllBytes(filePath, data);
|
||||
}
|
||||
|
||||
public void file_WriteAllBytes(string filePath, MemoryStream ms)
|
||||
{
|
||||
System.IO.File.WriteAllBytes(filePath, ms.ToArray());
|
||||
}
|
||||
|
||||
public void file_Delete(string filePath)
|
||||
{
|
||||
System.IO.File.Delete(filePath);
|
||||
}
|
||||
|
||||
public bool file_Exists(string filePath)
|
||||
{
|
||||
return System.IO.File.Exists(filePath);
|
||||
}
|
||||
|
||||
public byte[] file_ReadAllBytes(string filePath)
|
||||
{
|
||||
return System.IO.File.ReadAllBytes(filePath);
|
||||
}
|
||||
|
||||
}
|
||||
public class NintendoSwitchIO : IAxiIO
|
||||
{
|
||||
public NintendoSwitchIO()
|
||||
{
|
||||
AxiNS.instance.Init();
|
||||
}
|
||||
public void dir_CreateDirectory(string dirpath)
|
||||
{
|
||||
AxiNS.instance.io.CreateDir(dirpath);
|
||||
}
|
||||
|
||||
public void dir_Delete(string path, bool recursive)
|
||||
{
|
||||
AxiNS.instance.io.DeletePathFile(path);
|
||||
}
|
||||
|
||||
public IEnumerable<string> dir_EnumerateFiles(string path, string searchPattern)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool dir_Exists(string dirpath)
|
||||
{
|
||||
return AxiNS.instance.io.CheckPathExists(dirpath);
|
||||
}
|
||||
|
||||
public void file_Delete(string filePath)
|
||||
{
|
||||
AxiNS.instance.io.DeletePathFile(filePath);
|
||||
}
|
||||
|
||||
public bool file_Exists(string filePath)
|
||||
{
|
||||
return AxiNS.instance.io.CheckPathExists(filePath);
|
||||
}
|
||||
|
||||
public byte[] file_ReadAllBytes(string filePath)
|
||||
{
|
||||
return AxiNS.instance.io.LoadSwitchDataFile(filePath);
|
||||
}
|
||||
|
||||
public void file_WriteAllBytes(string filePath, byte[] data)
|
||||
{
|
||||
AxiNS.instance.io.FileToSaveWithCreate(filePath, data);
|
||||
}
|
||||
|
||||
public void file_WriteAllBytes(string filePath, MemoryStream ms)
|
||||
{
|
||||
AxiNS.instance.io.FileToSaveWithCreate(filePath,ms);
|
||||
}
|
||||
}
|
||||
public static class AxiIO
|
||||
{
|
||||
static IAxiIO m_io;
|
||||
public static IAxiIO io
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_io == null)
|
||||
{
|
||||
if (UnityEngine.Application.platform == RuntimePlatform.Switch)
|
||||
m_io = new NintendoSwitchIO();
|
||||
else
|
||||
m_io = new CSharpIO();
|
||||
}
|
||||
return m_io;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class File
|
||||
{
|
||||
internal static void Delete(string filePath)
|
||||
{
|
||||
AxiIO.io.file_Delete(filePath);
|
||||
}
|
||||
|
||||
internal static bool Exists(string filePath)
|
||||
{
|
||||
return AxiIO.io.file_Exists(filePath);
|
||||
}
|
||||
|
||||
internal static byte[] ReadAllBytes(string filePath)
|
||||
{
|
||||
return AxiIO.io.file_ReadAllBytes(filePath);
|
||||
}
|
||||
|
||||
internal static void WriteAllBytes(string path, byte[] data)
|
||||
{
|
||||
AxiIO.io.file_WriteAllBytes(path, data);
|
||||
}
|
||||
|
||||
internal static void WriteAllBytesFromStream(string path, MemoryStream ms)
|
||||
{
|
||||
AxiIO.io.file_WriteAllBytes(path, ms);
|
||||
}
|
||||
}
|
||||
public static class Directory
|
||||
{
|
||||
public static bool Exists(string dirpath)
|
||||
{
|
||||
return AxiIO.io.dir_Exists(dirpath);
|
||||
}
|
||||
|
||||
public static void CreateDirectory(string dirpath)
|
||||
{
|
||||
AxiIO.io.dir_CreateDirectory(dirpath);
|
||||
}
|
||||
|
||||
public static IEnumerable<string> EnumerateFiles(string path, string searchPattern)
|
||||
{
|
||||
return AxiIO.io.dir_EnumerateFiles(path, searchPattern);
|
||||
}
|
||||
|
||||
internal static void Delete(string cacheDirPath, bool v)
|
||||
{
|
||||
AxiIO.io.dir_Delete(cacheDirPath, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32f63f62398d8184590292135b011084
|
||||
@ -1,4 +1,4 @@
|
||||
{
|
||||
{
|
||||
"name": "AxibugEmuOnline.Client",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
@ -7,8 +7,9 @@
|
||||
"UIEffect2018",
|
||||
"Mame.Core",
|
||||
"Essgee.Unity",
|
||||
"StoicGooseUnity",
|
||||
"Unity.InputSystem"
|
||||
"StoicGooseUnity",
|
||||
"Unity.InputSystem",
|
||||
"AxiNSApi"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
//using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
@ -26,7 +26,7 @@ namespace AxibugEmuOnline.Client.Common
|
||||
|
||||
public static byte[] CompressByteArray(byte[] bytesToCompress)
|
||||
{
|
||||
using (var compressedMemoryStream = new MemoryStream())
|
||||
using (var compressedMemoryStream = new System.IO.MemoryStream())
|
||||
using (var gzipStream = new GZipStream(compressedMemoryStream, CompressionMode.Compress))
|
||||
{
|
||||
gzipStream.Write(bytesToCompress, 0, bytesToCompress.Length);
|
||||
@ -37,35 +37,35 @@ namespace AxibugEmuOnline.Client.Common
|
||||
|
||||
public static byte[] DecompressByteArray(byte[] compressedBytes)
|
||||
{
|
||||
using (var compressedMemoryStream = new MemoryStream(compressedBytes))
|
||||
using (var compressedMemoryStream = new System.IO.MemoryStream(compressedBytes))
|
||||
using (var gzipStream = new GZipStream(compressedMemoryStream, CompressionMode.Decompress))
|
||||
using (var resultMemoryStream = new MemoryStream())
|
||||
using (var resultMemoryStream = new System.IO.MemoryStream())
|
||||
{
|
||||
gzipStream.CopyTo(resultMemoryStream);
|
||||
return resultMemoryStream.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public static string FileMD5Hash(string filePath)
|
||||
{
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
using (var stream = File.OpenRead(filePath))
|
||||
{
|
||||
var hash = md5.ComputeHash(stream);
|
||||
var sb = new StringBuilder(hash.Length * 2);
|
||||
foreach (var b in hash)
|
||||
sb.AppendFormat("{0:x2}", b);
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
//public static string FileMD5Hash(string filePath)
|
||||
//{
|
||||
// using (var md5 = MD5.Create())
|
||||
// {
|
||||
// using (var stream = File.OpenRead(filePath))
|
||||
// {
|
||||
// var hash = md5.ComputeHash(stream);
|
||||
// var sb = new StringBuilder(hash.Length * 2);
|
||||
// foreach (var b in hash)
|
||||
// sb.AppendFormat("{0:x2}", b);
|
||||
// return sb.ToString();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
static byte[] FileMD5HashByte(byte[] data)
|
||||
{
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
using (var stream = new MemoryStream(data))
|
||||
using (var stream = new System.IO.MemoryStream(data))
|
||||
{
|
||||
return md5.ComputeHash(stream);
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
//using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
@ -20,8 +20,8 @@ namespace AxibugEmuOnline.Client
|
||||
/// <summary> 移除文件缓存 </summary>
|
||||
public void ClearCaches()
|
||||
{
|
||||
if (Directory.Exists(CacheDirPath))
|
||||
Directory.Delete(CacheDirPath, true);
|
||||
if (AxiIO.Directory.Exists(CacheDirPath))
|
||||
AxiIO.Directory.Delete(CacheDirPath, true);
|
||||
}
|
||||
|
||||
IEnumerator DownloadFromURL(string url, string path, Action<byte[]> callback)
|
||||
@ -38,8 +38,8 @@ namespace AxibugEmuOnline.Client
|
||||
|
||||
if (!request.downloadHandler.bHadErr)
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
File.WriteAllBytes($"{path}/{url.GetHashCode()}", request.downloadHandler.data);
|
||||
AxiIO.Directory.CreateDirectory(path);
|
||||
AxiIO.File.WriteAllBytes($"{path}/{url.GetHashCode()}", request.downloadHandler.data);
|
||||
callback.Invoke(request.downloadHandler.data);
|
||||
}
|
||||
else
|
||||
@ -78,9 +78,9 @@ namespace AxibugEmuOnline.Client
|
||||
byte[] rawData = null;
|
||||
|
||||
var filePath = $"{path}/{fileName}";
|
||||
if (File.Exists(filePath))
|
||||
if (AxiIO.File.Exists(filePath))
|
||||
{
|
||||
rawData = File.ReadAllBytes(filePath);
|
||||
rawData = AxiIO.File.ReadAllBytes(filePath);
|
||||
var @out = RawDataConvert<T>(rawData);
|
||||
cachesInMemory[url] = @out;
|
||||
callback.Invoke(@out, url);
|
||||
|
||||
@ -5,7 +5,7 @@ using ICSharpCode.SharpZipLib.Zip;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
//using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
@ -208,9 +208,9 @@ namespace AxibugEmuOnline.Client
|
||||
if (App.FileDownloader.GetDownloadProgress(webData.url) == null)
|
||||
{
|
||||
if (MultiFileRom)
|
||||
m_hasLocalFile = Directory.Exists(LocalFilePath);
|
||||
m_hasLocalFile = AxiIO.Directory.Exists(LocalFilePath);
|
||||
else
|
||||
m_hasLocalFile = File.Exists(LocalFilePath);
|
||||
m_hasLocalFile = AxiIO.File.Exists(LocalFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
@ -242,7 +242,7 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
Dictionary<string, byte[]> unzipFiles = new Dictionary<string, byte[]>();
|
||||
//多rom文件的平台,下载下来的数据直接解压放入文件夹内
|
||||
var zip = new ZipInputStream(new MemoryStream(bytes));
|
||||
var zip = new ZipInputStream(new System.IO.MemoryStream(bytes));
|
||||
|
||||
List<string> depth0Files = new List<string>();
|
||||
while (true)
|
||||
@ -253,7 +253,7 @@ namespace AxibugEmuOnline.Client
|
||||
if (currentEntry.IsDirectory) continue;
|
||||
|
||||
var buffer = new byte[1024];
|
||||
MemoryStream output = new MemoryStream();
|
||||
System.IO.MemoryStream output = new System.IO.MemoryStream();
|
||||
while (true)
|
||||
{
|
||||
var size = zip.Read(buffer, 0, buffer.Length);
|
||||
@ -275,16 +275,16 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
var path = rootDirName != null ? item.Key.Substring(0, rootDirName.Length + 1) : item.Key;
|
||||
var data = item.Value;
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
File.WriteAllBytes(path, data);
|
||||
AxiIO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path));
|
||||
AxiIO.File.WriteAllBytes(path, data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var directPath = Path.GetDirectoryName(LocalFilePath);
|
||||
Directory.CreateDirectory(directPath);
|
||||
var directPath = System.IO.Path.GetDirectoryName(LocalFilePath);
|
||||
AxiIO.Directory.CreateDirectory(directPath);
|
||||
|
||||
File.WriteAllBytes(LocalFilePath, bytes);
|
||||
AxiIO.File.WriteAllBytes(LocalFilePath, bytes);
|
||||
}
|
||||
Eventer.Instance.PostEvent(EEvent.OnRomFileDownloaded, ID);
|
||||
OnDownloadOver?.Invoke(this);
|
||||
@ -297,10 +297,10 @@ namespace AxibugEmuOnline.Client
|
||||
if (webData == null) throw new Exception("Not Valid Rom");
|
||||
if (!RomReady) throw new Exception("Rom File Not Downloaded");
|
||||
|
||||
var bytes = File.ReadAllBytes(LocalFilePath);
|
||||
if (Path.GetExtension(LocalFilePath).ToLower() == ".zip")
|
||||
var bytes = AxiIO.File.ReadAllBytes(LocalFilePath);
|
||||
if (System.IO.Path.GetExtension(LocalFilePath).ToLower() == ".zip")
|
||||
{
|
||||
var zip = new ZipInputStream(new MemoryStream(bytes));
|
||||
var zip = new ZipInputStream(new System.IO.MemoryStream(bytes));
|
||||
while (true)
|
||||
{
|
||||
var currentEntry = zip.GetNextEntry();
|
||||
@ -310,7 +310,7 @@ namespace AxibugEmuOnline.Client
|
||||
if (!currentEntry.Name.ToLower().EndsWith(FileExtentionName)) continue;
|
||||
|
||||
var buffer = new byte[1024];
|
||||
MemoryStream output = new MemoryStream();
|
||||
System.IO.MemoryStream output = new System.IO.MemoryStream();
|
||||
while (true)
|
||||
{
|
||||
var size = zip.Read(buffer, 0, buffer.Length);
|
||||
@ -332,7 +332,7 @@ namespace AxibugEmuOnline.Client
|
||||
public void SetWebData(HttpAPI.Resp_RomInfo resp_RomInfo)
|
||||
{
|
||||
webData = resp_RomInfo;
|
||||
FileName = MultiFileRom ? Path.GetFileNameWithoutExtension(webData.url) : Path.GetFileName(webData.url);
|
||||
FileName = MultiFileRom ? System.IO.Path.GetFileNameWithoutExtension(webData.url) : System.IO.Path.GetFileName(webData.url);
|
||||
FileName = System.Net.WebUtility.UrlDecode(FileName);
|
||||
|
||||
//收集依赖Rom
|
||||
|
||||
@ -4,7 +4,7 @@ using AxibugEmuOnline.Client.Event;
|
||||
using AxibugProtobuf;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
//using System.IO;
|
||||
using System.Linq;
|
||||
using static AxibugEmuOnline.Client.HttpAPI;
|
||||
|
||||
@ -62,14 +62,14 @@ namespace AxibugEmuOnline.Client
|
||||
public void ClearRomFile()
|
||||
{
|
||||
var path = $"{App.PersistentDataPath(m_platform)}/RemoteRoms";
|
||||
if (Directory.Exists(path)) Directory.Delete(path, true);
|
||||
if (AxiIO.Directory.Exists(path)) AxiIO.Directory.Delete(path, true);
|
||||
}
|
||||
|
||||
/// <summary> 移除一个已下载的Rom </summary>
|
||||
public void RemoveOneRomFile(RomFile romFile)
|
||||
{
|
||||
if (romFile.RomReady)
|
||||
File.Delete(romFile.LocalFilePath);
|
||||
AxiIO.File.Delete(romFile.LocalFilePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.Tools;
|
||||
using AxibugProtobuf;
|
||||
using MAME.Core;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
//using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
@ -32,7 +32,7 @@ namespace AxibugEmuOnline.Client
|
||||
var path = App.UserPersistenDataPath(EmuPlatform);
|
||||
path = $"{path}/Slot/{RomID}";
|
||||
|
||||
Directory.CreateDirectory(path);
|
||||
AxiIO.Directory.CreateDirectory(path);
|
||||
|
||||
var filePath = $"{path}/slot{SlotIndex}.SlotSav";
|
||||
return filePath;
|
||||
@ -80,25 +80,37 @@ namespace AxibugEmuOnline.Client
|
||||
FSM.AddState<SyncedState>();
|
||||
FSM.OnStateChanged += FSM_OnStateChanged;
|
||||
|
||||
IsEmpty = !File.Exists(FilePath);
|
||||
IsEmpty = !AxiIO.File.Exists(FilePath);
|
||||
|
||||
if (IsEmpty) Sequecen = 0;
|
||||
else //从文件头读取存储序号
|
||||
{
|
||||
byte[] saveOrderData = new byte[4];
|
||||
var streaming = File.OpenRead(FilePath);
|
||||
int res = streaming.Read(saveOrderData, 0, 4);
|
||||
if (res != 4) //无效的存档文件
|
||||
|
||||
//FileStream streaming = System.IO.File.OpenRead(FilePath);
|
||||
//int res = streaming.Read(saveOrderData, 0, 4);
|
||||
//if (res != 4) //无效的存档文件
|
||||
//{
|
||||
// IsEmpty = true;
|
||||
// File.Delete(FilePath);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// Sequecen = BitConverter.ToUInt32(saveOrderData, 0);
|
||||
//}
|
||||
//streaming.Dispose();
|
||||
|
||||
byte[] bytes = AxiIO.File.ReadAllBytes(FilePath);
|
||||
if (bytes.Length < 4) //无效的存档文件
|
||||
{
|
||||
IsEmpty = true;
|
||||
File.Delete(FilePath);
|
||||
AxiIO.File.Delete(FilePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
Array.Copy(bytes, 0, saveOrderData, 0, 4);
|
||||
Sequecen = BitConverter.ToUInt32(saveOrderData, 0);
|
||||
}
|
||||
|
||||
streaming.Dispose();
|
||||
}
|
||||
|
||||
FSM.ChangeState<IdleState>();
|
||||
@ -138,9 +150,9 @@ namespace AxibugEmuOnline.Client
|
||||
savData = null;
|
||||
screenShotData = null;
|
||||
|
||||
if (!File.Exists(FilePath)) return;
|
||||
if (!AxiIO.File.Exists(FilePath)) return;
|
||||
|
||||
var raw = File.ReadAllBytes(FilePath);
|
||||
var raw = AxiIO.File.ReadAllBytes(FilePath);
|
||||
int headerSize = Marshal.SizeOf(typeof(Header));
|
||||
|
||||
if (raw.Length < headerSize)
|
||||
@ -199,7 +211,7 @@ namespace AxibugEmuOnline.Client
|
||||
Array.Copy(savData, 0, raw, headerSize, savData.Length);
|
||||
Array.Copy(screenShotData, 0, raw, headerSize + savData.Length, screenShotData.Length);
|
||||
|
||||
File.WriteAllBytes(filePath, raw);
|
||||
AxiIO.File.WriteAllBytes(filePath, raw);
|
||||
Sequecen = sequence;
|
||||
|
||||
m_headerCache = header;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
//using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
@ -103,9 +103,9 @@ namespace AxibugEmuOnline.Client
|
||||
string GetSavePath()
|
||||
{
|
||||
string dir = $"{App.PersistentDataPath(App.emu.Core.Platform)}/AxiSoundRecord";
|
||||
if (!Directory.Exists(dir))
|
||||
if (!AxiIO.Directory.Exists(dir))
|
||||
{
|
||||
Directory.CreateDirectory(dir);
|
||||
AxiIO.Directory.CreateDirectory(dir);
|
||||
}
|
||||
return $"{dir}/{App.tick.GetDateTimeStr()}";
|
||||
}
|
||||
@ -132,13 +132,21 @@ namespace AxibugEmuOnline.Client
|
||||
OverlayManager.PopTip("没有录音数据");
|
||||
return;
|
||||
}
|
||||
|
||||
using (FileStream file = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
|
||||
using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
|
||||
{
|
||||
file.Write(waveHeader.GetBytes(), 0, (int)waveHeader.Length());
|
||||
file.Write(formatChunk.GetBytes(), 0, (int)formatChunk.Length());
|
||||
file.Write(dataChunk.GetBytes(), 0, (int)dataChunk.Length());
|
||||
ms.Write(waveHeader.GetBytes(), 0, (int)waveHeader.Length());
|
||||
ms.Write(formatChunk.GetBytes(), 0, (int)formatChunk.Length());
|
||||
ms.Write(dataChunk.GetBytes(), 0, (int)dataChunk.Length());
|
||||
AxiIO.File.WriteAllBytesFromStream(filename, ms);
|
||||
}
|
||||
|
||||
//using (FileStream file = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
|
||||
//{
|
||||
// file.Write(waveHeader.GetBytes(), 0, (int)waveHeader.Length());
|
||||
// file.Write(formatChunk.GetBytes(), 0, (int)formatChunk.Length());
|
||||
// file.Write(dataChunk.GetBytes(), 0, (int)dataChunk.Length());
|
||||
//}
|
||||
|
||||
IsRecording = false;
|
||||
OverlayManager.PopTip("录音结束");
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user