parent
f6e94c9514
commit
895dde1cc8
|
@ -61,7 +61,7 @@ namespace YooAsset.Editor
|
|||
File.Delete(savePath);
|
||||
|
||||
string json = JsonUtility.ToJson(buildReport, true);
|
||||
FileUtility.CreateFile(savePath, json);
|
||||
FileUtility.WriteAllText(savePath, json);
|
||||
}
|
||||
public static BuildReport Deserialize(string jsonData)
|
||||
{
|
||||
|
|
|
@ -98,7 +98,7 @@ namespace YooAsset.Editor
|
|||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
FileUtility.CreateFile(filePath, packageHash);
|
||||
FileUtility.WriteAllText(filePath, packageHash);
|
||||
BuildLogger.Log($"创建补丁清单哈希文件:{filePath}");
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ namespace YooAsset.Editor
|
|||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildParameters.PackageName);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
FileUtility.CreateFile(filePath, buildParameters.PackageVersion);
|
||||
FileUtility.WriteAllText(filePath, buildParameters.PackageVersion);
|
||||
BuildLogger.Log($"创建补丁清单版本文件:{filePath}");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace YooAsset.Editor
|
|||
}
|
||||
|
||||
string filePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}.encrypt";
|
||||
FileUtility.CreateFile(filePath, encryptResult.EncryptedData);
|
||||
FileUtility.WriteAllBytes(filePath, encryptResult.EncryptedData);
|
||||
bundleInfo.EncryptedFilePath = filePath;
|
||||
bundleInfo.LoadMethod = encryptResult.LoadMethod;
|
||||
BuildLogger.Log($"Bundle文件加密完成:{filePath}");
|
||||
|
|
|
@ -278,7 +278,7 @@ namespace YooAsset.Editor
|
|||
|
||||
string filePath = $"{resultPath}/{nameof(DebugReport)}_{_currentReport.FrameCount}.json";
|
||||
string fileContent = JsonUtility.ToJson(_currentReport, true);
|
||||
FileUtility.CreateFile(filePath, fileContent);
|
||||
FileUtility.WriteAllText(filePath, fileContent);
|
||||
}
|
||||
}
|
||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||
|
|
|
@ -86,9 +86,7 @@ namespace YooAsset
|
|||
if (IsValidWithWarning == false)
|
||||
return null;
|
||||
string filePath = Provider.RawFilePath;
|
||||
if (File.Exists(filePath) == false)
|
||||
return null;
|
||||
return File.ReadAllText(filePath, Encoding.UTF8);
|
||||
return FileUtility.ReadAllText(filePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace YooAsset
|
|||
public static void SerializeToJson(string savePath, PackageManifest manifest)
|
||||
{
|
||||
string json = JsonUtility.ToJson(manifest, true);
|
||||
FileUtility.CreateFile(savePath, json);
|
||||
FileUtility.WriteAllText(savePath, json);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -410,7 +410,7 @@ namespace YooAsset
|
|||
_footPrint = Application.buildGUID;
|
||||
#endif
|
||||
string footPrintFilePath = PersistentTools.GetAppFootPrintFilePath();
|
||||
FileUtility.CreateFile(footPrintFilePath, _footPrint);
|
||||
FileUtility.WriteAllText(footPrintFilePath, _footPrint);
|
||||
YooLogger.Log($"Save application foot print : {_footPrint}");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace YooAsset
|
|||
internal static class StringUtility
|
||||
{
|
||||
[ThreadStatic]
|
||||
private static StringBuilder _cacheBuilder = new StringBuilder(1024);
|
||||
private static StringBuilder _cacheBuilder = new StringBuilder(2048);
|
||||
|
||||
public static string Format(string format, object arg0)
|
||||
{
|
||||
|
@ -106,46 +106,26 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建文件(如果已经存在则删除旧文件)
|
||||
/// 写入文本数据(会覆盖指定路径的文件)
|
||||
/// </summary>
|
||||
public static void CreateFile(string filePath, string content)
|
||||
public static void WriteAllText(string filePath, string content)
|
||||
{
|
||||
// 删除旧文件
|
||||
if (File.Exists(filePath))
|
||||
File.Delete(filePath);
|
||||
|
||||
// 创建文件夹路径
|
||||
CreateFileDirectory(filePath);
|
||||
|
||||
// 创建新文件
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(content);
|
||||
using (FileStream fs = File.Create(filePath))
|
||||
{
|
||||
fs.Write(bytes, 0, bytes.Length);
|
||||
fs.Flush();
|
||||
fs.Close();
|
||||
}
|
||||
File.WriteAllBytes(filePath, bytes); //避免写入BOM标记
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建文件(如果已经存在则删除旧文件)
|
||||
/// 写入字节数据(会覆盖指定路径的文件)
|
||||
/// </summary>
|
||||
public static void CreateFile(string filePath, byte[] data)
|
||||
public static void WriteAllBytes(string filePath, byte[] data)
|
||||
{
|
||||
// 删除旧文件
|
||||
if (File.Exists(filePath))
|
||||
File.Delete(filePath);
|
||||
|
||||
// 创建文件夹路径
|
||||
CreateFileDirectory(filePath);
|
||||
|
||||
// 创建新文件
|
||||
using (FileStream fs = File.Create(filePath))
|
||||
{
|
||||
fs.Write(data, 0, data.Length);
|
||||
fs.Flush();
|
||||
fs.Close();
|
||||
}
|
||||
File.WriteAllBytes(filePath, data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue