diff --git a/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/Asset.cs b/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/Asset.cs index 3c268c8..a75ec02 100644 --- a/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/Asset.cs +++ b/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/Asset.cs @@ -1,7 +1,7 @@ namespace LocalTools { using SpoiledCat.Json; - using SpoiledCat.NiceIO; + using SpoiledCat.SimpleIO; using SpoiledCat.Utilities; /// @@ -10,11 +10,11 @@ public struct Asset { private string hash; - private NPath path; + private SPath path; private UriString url; private bool needsUnzip; - public Asset(Asset asset, NPath localPath) + public Asset(Asset asset, SPath localPath) { hash = asset.hash; path = asset.path; @@ -25,10 +25,10 @@ public Asset(Asset asset, NPath localPath) } [NotSerialized] public UriString Url { get => url; set => url = value; } - [NotSerialized] public NPath Path { get => path; set => path = value; } + [NotSerialized] public SPath Path { get => path; set => path = value; } [NotSerialized] public string Hash { get => hash; set => hash = value; } [NotSerialized] public bool NeedsUnzip { get => needsUnzip; set => needsUnzip = value; } - [NotSerialized] public NPath LocalPath { get; set; } + [NotSerialized] public SPath LocalPath { get; set; } [NotSerialized] public string Filename => url?.Filename ?? ""; [NotSerialized] public bool NeedsDownload { get; set; } } diff --git a/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/Extensions.cs b/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/Extensions.cs index dca01c0..5c039ec 100644 --- a/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/Extensions.cs +++ b/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/Extensions.cs @@ -2,16 +2,16 @@ { using System; using System.Security.Cryptography; - using SpoiledCat.NiceIO; + using SpoiledCat.SimpleIO; public static class Extensions { - public static string ToMD5(this NPath path) + public static string ToMD5(this SPath path) { byte[] computeHash; using (var md5 = MD5.Create()) { - using (var stream = NPath.FileSystem.OpenRead(path.MakeAbsolute())) + using (var stream = SPath.FileSystem.OpenRead(path.MakeAbsolute())) { computeHash = md5.ComputeHash(stream); } diff --git a/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/Index.cs b/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/Index.cs index d668746..9400558 100644 --- a/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/Index.cs +++ b/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/Index.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using SpoiledCat.Json; - using SpoiledCat.NiceIO; + using SpoiledCat.SimpleIO; public struct Index { @@ -20,10 +20,10 @@ public Index(List assets) this.assets = assets; } - public static Index Load(NPath indexFile) => indexFile.ReadAllText().FromJson(true, false); - public static Index Load(string indexFile) => Load(indexFile.ToNPath()); + public static Index Load(SPath indexFile) => indexFile.ReadAllText().FromJson(true, false); + public static Index Load(string indexFile) => Load(indexFile.ToSPath()); - public void Save(NPath indexFile) => indexFile.WriteAllText(this.ToJson(true, false)); - public void Save(string indexFile) => Save(indexFile.ToNPath()); + public void Save(SPath indexFile) => indexFile.WriteAllText(this.ToJson(true, false)); + public void Save(string indexFile) => Save(indexFile.ToSPath()); } } diff --git a/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/LargeAssetManager.asmdef b/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/LargeAssetManager.asmdef index e8e5bf4..072643f 100644 --- a/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/LargeAssetManager.asmdef +++ b/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/LargeAssetManager.asmdef @@ -1,7 +1,7 @@ { "name": "LargeAssetManager", "references": [ - "com.spoiledcat.niceio", + "com.spoiledcat.simpleio", "com.spoiledcat.simplejson", "com.spoiledcat.logging", "com.spoiledcat.threading", diff --git a/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/LargeAssetManager.cs b/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/LargeAssetManager.cs index 46f3587..fd56d89 100644 --- a/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/LargeAssetManager.cs +++ b/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/LargeAssetManager.cs @@ -4,7 +4,7 @@ using LocalTools; using SpoiledCat.Json; using SpoiledCat.Logging; -using SpoiledCat.NiceIO; +using SpoiledCat.SimpleIO; using SpoiledCat.Threading; using SpoiledCat.Utilities; using UnityEditor; @@ -20,15 +20,15 @@ public class LargeAssetManager static LargeAssetManager() { - PocoJsonSerializerStrategy.RegisterCustomTypeHandler( - value => (((NPath)value).ToString(SlashMode.Forward), true), + PocoJsonSerializerStrategy.RegisterCustomTypeHandler( + value => (((SPath)value).ToString(SlashMode.Forward), true), (value, type) => { string str = value as string; if (!string.IsNullOrEmpty(str)) { - return (new NPath(str), true); + return (new SPath(str), true); } - return (NPath.Default, true); + return (SPath.Default, true); }); PocoJsonSerializerStrategy.RegisterCustomTypeHandler(value => (value.ToString(), true), @@ -66,7 +66,7 @@ private static void ClearProgress() } - public static void UpdateIndexFromFilesInFolder(NPath template, NPath indexPath, NPath path) + public static void UpdateIndexFromFilesInFolder(SPath template, SPath indexPath, SPath path) { var runTask = UpdateIndexFromFilesInFolderTask(path, indexPath, template); @@ -80,7 +80,7 @@ public static void UpdateIndexFromFilesInFolder(NPath template, NPath indexPath, .Start(); } - public static ITask UpdateIndexFromFilesInFolderTask(NPath folderWithFiles, NPath indexFileToGenerate, NPath? indexTemplate = null) + public static ITask UpdateIndexFromFilesInFolderTask(SPath folderWithFiles, SPath indexFileToGenerate, SPath? indexTemplate = null) { Index? templateIndex = null; if (indexTemplate.HasValue && indexTemplate.Value.FileExists()) @@ -105,7 +105,7 @@ public static ITask UpdateIndexFromFilesInFolderTask(NPath folderWithFiles, NPat else { asset.LocalPath = file; - asset.Path = file.FileNameWithoutExtension.ToNPath(); + asset.Path = file.FileNameWithoutExtension.ToSPath(); asset.NeedsUnzip = file.ExtensionWithDot == ".zip" ? true : false; asset.Url = $"{DefaultWebServerUrl}:{DefaultWebServerPort}/assets/{dt}/{file.FileName}"; } @@ -173,11 +173,11 @@ public static void JustUnzip() { var index = Index.Load("index.json"); - var downloads = "Downloads".ToNPath().MakeAbsolute(); + var downloads = "Downloads".ToSPath().MakeAbsolute(); List assetList = new List(); foreach (var asset in index.Assets.Where(x => x.NeedsUnzip)) { - NPath file = downloads.Combine(asset.Filename); + SPath file = downloads.Combine(asset.Filename); if (file.FileExists()) assetList.Add(new Asset(asset, downloads.Combine(asset.Filename))); } @@ -197,14 +197,14 @@ public static void JustUnzip() private static TaskQueue CalculateWhatNeedsToBeDownloaded(Index index) { - var downloads = "Downloads".ToNPath().MakeAbsolute(); + var downloads = "Downloads".ToSPath().MakeAbsolute(); List downloadList = new List(); TaskQueue t = new TaskQueue(TaskManager) { Message = "Calculating hashes..." }; foreach (var entry in index.Assets) { t.Queue(new FuncTask(TaskManager, (_, asset) => { - NPath file; + SPath file; if (asset.NeedsUnzip) { file = downloads.Combine(asset.Filename); @@ -261,9 +261,9 @@ public static ITask> DownloadIfNeeded(Index index) }); } - public static TaskQueue Unzip(List assetList) + public static TaskQueue Unzip(List assetList) { - var unzipper = new TaskQueue(TaskManager); + var unzipper = new TaskQueue(TaskManager); foreach (var asset in assetList.Where(x => x.NeedsUnzip)) { var unzipStamp = asset.LocalPath.Parent.Combine($".{asset.Filename}"); diff --git a/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/LargeAssetManagerWindow.cs b/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/LargeAssetManagerWindow.cs index 9bf2ee0..6e98076 100644 --- a/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/LargeAssetManagerWindow.cs +++ b/UnityProjects/UnityTools Local Built Packages/Assets/Tools/LargeAssetManager/LargeAssetManagerWindow.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; using SpoiledCat.Logging; -using SpoiledCat.NiceIO; +using SpoiledCat.SimpleIO; using SpoiledCat.ProcessManager; using SpoiledCat.Threading; using SpoiledCat.UI; @@ -76,10 +76,10 @@ private void JustUnzip() private void CreateIndex() { LargeAssetManager.TaskManager = TaskManager; - string folder = EditorUtility.OpenFolderPanel("Select Folder with zip files to add to the index", "../../Helpers/Helper.WebServer/files/assets".ToNPath().Resolve(), ""); + string folder = EditorUtility.OpenFolderPanel("Select Folder with zip files to add to the index", "../../Helpers/Helper.WebServer/files/assets".ToSPath().Resolve(), ""); if (!string.IsNullOrEmpty(folder)) { - LargeAssetManager.UpdateIndexFromFilesInFolder("index-template.json".ToNPath(), "index.json".ToNPath(), folder.ToNPath()); + LargeAssetManager.UpdateIndexFromFilesInFolder("index-template.json".ToSPath(), "index.json".ToSPath(), folder.ToSPath()); } } @@ -114,7 +114,7 @@ public override async void OnUI() if (GUILayout.Button("Start Web Server")) { webServerTask = new ProcessTaskLongRunning(TaskManager, ProcessEnvironment, - "Packages/com.spoiledcat.processmanager/Tests/Helpers~/Helper.CommandLine.exe".ToNPath().Resolve(), + "Packages/com.spoiledcat.processmanager/Tests/Helpers~/Helper.CommandLine.exe".ToSPath().Resolve(), $"-w -p {webServerPort}").Configure(new ProcessManager(Environment, TaskManager.Token)); diff --git a/UnityProjects/UnityTools Local Built Packages/Packages/manifest.json b/UnityProjects/UnityTools Local Built Packages/Packages/manifest.json index 6e148ad..6c48617 100644 --- a/UnityProjects/UnityTools Local Built Packages/Packages/manifest.json +++ b/UnityProjects/UnityTools Local Built Packages/Packages/manifest.json @@ -2,7 +2,7 @@ "dependencies": { "com.spoiledcat.environment": "file:../../../../build/packages/com.spoiledcat.environment", "com.spoiledcat.logging": "file:../../../../build/packages/com.spoiledcat.logging", - "com.spoiledcat.niceio": "file:../../../../build/packages/com.spoiledcat.niceio", + "com.spoiledcat.simpleio": "file:../../../../build/packages/com.spoiledcat.simpleio", "com.spoiledcat.processmanager": "file:../../../../build/packages/com.spoiledcat.processmanager", "com.spoiledcat.processmanager.tests": "file:../../../../build/packages/com.spoiledcat.processmanager.tests", "com.spoiledcat.quick-console": "file:../../../../build/packages/com.spoiledcat.quick-console", diff --git a/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/Asset.cs b/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/Asset.cs index 3c268c8..a75ec02 100644 --- a/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/Asset.cs +++ b/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/Asset.cs @@ -1,7 +1,7 @@ namespace LocalTools { using SpoiledCat.Json; - using SpoiledCat.NiceIO; + using SpoiledCat.SimpleIO; using SpoiledCat.Utilities; /// @@ -10,11 +10,11 @@ public struct Asset { private string hash; - private NPath path; + private SPath path; private UriString url; private bool needsUnzip; - public Asset(Asset asset, NPath localPath) + public Asset(Asset asset, SPath localPath) { hash = asset.hash; path = asset.path; @@ -25,10 +25,10 @@ public Asset(Asset asset, NPath localPath) } [NotSerialized] public UriString Url { get => url; set => url = value; } - [NotSerialized] public NPath Path { get => path; set => path = value; } + [NotSerialized] public SPath Path { get => path; set => path = value; } [NotSerialized] public string Hash { get => hash; set => hash = value; } [NotSerialized] public bool NeedsUnzip { get => needsUnzip; set => needsUnzip = value; } - [NotSerialized] public NPath LocalPath { get; set; } + [NotSerialized] public SPath LocalPath { get; set; } [NotSerialized] public string Filename => url?.Filename ?? ""; [NotSerialized] public bool NeedsDownload { get; set; } } diff --git a/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/Extensions.cs b/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/Extensions.cs index dca01c0..5c039ec 100644 --- a/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/Extensions.cs +++ b/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/Extensions.cs @@ -2,16 +2,16 @@ { using System; using System.Security.Cryptography; - using SpoiledCat.NiceIO; + using SpoiledCat.SimpleIO; public static class Extensions { - public static string ToMD5(this NPath path) + public static string ToMD5(this SPath path) { byte[] computeHash; using (var md5 = MD5.Create()) { - using (var stream = NPath.FileSystem.OpenRead(path.MakeAbsolute())) + using (var stream = SPath.FileSystem.OpenRead(path.MakeAbsolute())) { computeHash = md5.ComputeHash(stream); } diff --git a/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/Index.cs b/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/Index.cs index d668746..9400558 100644 --- a/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/Index.cs +++ b/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/Index.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using SpoiledCat.Json; - using SpoiledCat.NiceIO; + using SpoiledCat.SimpleIO; public struct Index { @@ -20,10 +20,10 @@ public Index(List assets) this.assets = assets; } - public static Index Load(NPath indexFile) => indexFile.ReadAllText().FromJson(true, false); - public static Index Load(string indexFile) => Load(indexFile.ToNPath()); + public static Index Load(SPath indexFile) => indexFile.ReadAllText().FromJson(true, false); + public static Index Load(string indexFile) => Load(indexFile.ToSPath()); - public void Save(NPath indexFile) => indexFile.WriteAllText(this.ToJson(true, false)); - public void Save(string indexFile) => Save(indexFile.ToNPath()); + public void Save(SPath indexFile) => indexFile.WriteAllText(this.ToJson(true, false)); + public void Save(string indexFile) => Save(indexFile.ToSPath()); } } diff --git a/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/LargeAssetManager.asmdef b/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/LargeAssetManager.asmdef index e8e5bf4..072643f 100644 --- a/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/LargeAssetManager.asmdef +++ b/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/LargeAssetManager.asmdef @@ -1,7 +1,7 @@ { "name": "LargeAssetManager", "references": [ - "com.spoiledcat.niceio", + "com.spoiledcat.simpleio", "com.spoiledcat.simplejson", "com.spoiledcat.logging", "com.spoiledcat.threading", diff --git a/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/LargeAssetManager.cs b/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/LargeAssetManager.cs index 46f3587..fd56d89 100644 --- a/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/LargeAssetManager.cs +++ b/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/LargeAssetManager.cs @@ -4,7 +4,7 @@ using LocalTools; using SpoiledCat.Json; using SpoiledCat.Logging; -using SpoiledCat.NiceIO; +using SpoiledCat.SimpleIO; using SpoiledCat.Threading; using SpoiledCat.Utilities; using UnityEditor; @@ -20,15 +20,15 @@ public class LargeAssetManager static LargeAssetManager() { - PocoJsonSerializerStrategy.RegisterCustomTypeHandler( - value => (((NPath)value).ToString(SlashMode.Forward), true), + PocoJsonSerializerStrategy.RegisterCustomTypeHandler( + value => (((SPath)value).ToString(SlashMode.Forward), true), (value, type) => { string str = value as string; if (!string.IsNullOrEmpty(str)) { - return (new NPath(str), true); + return (new SPath(str), true); } - return (NPath.Default, true); + return (SPath.Default, true); }); PocoJsonSerializerStrategy.RegisterCustomTypeHandler(value => (value.ToString(), true), @@ -66,7 +66,7 @@ private static void ClearProgress() } - public static void UpdateIndexFromFilesInFolder(NPath template, NPath indexPath, NPath path) + public static void UpdateIndexFromFilesInFolder(SPath template, SPath indexPath, SPath path) { var runTask = UpdateIndexFromFilesInFolderTask(path, indexPath, template); @@ -80,7 +80,7 @@ public static void UpdateIndexFromFilesInFolder(NPath template, NPath indexPath, .Start(); } - public static ITask UpdateIndexFromFilesInFolderTask(NPath folderWithFiles, NPath indexFileToGenerate, NPath? indexTemplate = null) + public static ITask UpdateIndexFromFilesInFolderTask(SPath folderWithFiles, SPath indexFileToGenerate, SPath? indexTemplate = null) { Index? templateIndex = null; if (indexTemplate.HasValue && indexTemplate.Value.FileExists()) @@ -105,7 +105,7 @@ public static ITask UpdateIndexFromFilesInFolderTask(NPath folderWithFiles, NPat else { asset.LocalPath = file; - asset.Path = file.FileNameWithoutExtension.ToNPath(); + asset.Path = file.FileNameWithoutExtension.ToSPath(); asset.NeedsUnzip = file.ExtensionWithDot == ".zip" ? true : false; asset.Url = $"{DefaultWebServerUrl}:{DefaultWebServerPort}/assets/{dt}/{file.FileName}"; } @@ -173,11 +173,11 @@ public static void JustUnzip() { var index = Index.Load("index.json"); - var downloads = "Downloads".ToNPath().MakeAbsolute(); + var downloads = "Downloads".ToSPath().MakeAbsolute(); List assetList = new List(); foreach (var asset in index.Assets.Where(x => x.NeedsUnzip)) { - NPath file = downloads.Combine(asset.Filename); + SPath file = downloads.Combine(asset.Filename); if (file.FileExists()) assetList.Add(new Asset(asset, downloads.Combine(asset.Filename))); } @@ -197,14 +197,14 @@ public static void JustUnzip() private static TaskQueue CalculateWhatNeedsToBeDownloaded(Index index) { - var downloads = "Downloads".ToNPath().MakeAbsolute(); + var downloads = "Downloads".ToSPath().MakeAbsolute(); List downloadList = new List(); TaskQueue t = new TaskQueue(TaskManager) { Message = "Calculating hashes..." }; foreach (var entry in index.Assets) { t.Queue(new FuncTask(TaskManager, (_, asset) => { - NPath file; + SPath file; if (asset.NeedsUnzip) { file = downloads.Combine(asset.Filename); @@ -261,9 +261,9 @@ public static ITask> DownloadIfNeeded(Index index) }); } - public static TaskQueue Unzip(List assetList) + public static TaskQueue Unzip(List assetList) { - var unzipper = new TaskQueue(TaskManager); + var unzipper = new TaskQueue(TaskManager); foreach (var asset in assetList.Where(x => x.NeedsUnzip)) { var unzipStamp = asset.LocalPath.Parent.Combine($".{asset.Filename}"); diff --git a/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/LargeAssetManagerWindow.cs b/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/LargeAssetManagerWindow.cs index 9bf2ee0..6e98076 100644 --- a/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/LargeAssetManagerWindow.cs +++ b/UnityProjects/UnityTools Package Project/Assets/Tools/LargeAssetManager/LargeAssetManagerWindow.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; using SpoiledCat.Logging; -using SpoiledCat.NiceIO; +using SpoiledCat.SimpleIO; using SpoiledCat.ProcessManager; using SpoiledCat.Threading; using SpoiledCat.UI; @@ -76,10 +76,10 @@ private void JustUnzip() private void CreateIndex() { LargeAssetManager.TaskManager = TaskManager; - string folder = EditorUtility.OpenFolderPanel("Select Folder with zip files to add to the index", "../../Helpers/Helper.WebServer/files/assets".ToNPath().Resolve(), ""); + string folder = EditorUtility.OpenFolderPanel("Select Folder with zip files to add to the index", "../../Helpers/Helper.WebServer/files/assets".ToSPath().Resolve(), ""); if (!string.IsNullOrEmpty(folder)) { - LargeAssetManager.UpdateIndexFromFilesInFolder("index-template.json".ToNPath(), "index.json".ToNPath(), folder.ToNPath()); + LargeAssetManager.UpdateIndexFromFilesInFolder("index-template.json".ToSPath(), "index.json".ToSPath(), folder.ToSPath()); } } @@ -114,7 +114,7 @@ public override async void OnUI() if (GUILayout.Button("Start Web Server")) { webServerTask = new ProcessTaskLongRunning(TaskManager, ProcessEnvironment, - "Packages/com.spoiledcat.processmanager/Tests/Helpers~/Helper.CommandLine.exe".ToNPath().Resolve(), + "Packages/com.spoiledcat.processmanager/Tests/Helpers~/Helper.CommandLine.exe".ToSPath().Resolve(), $"-w -p {webServerPort}").Configure(new ProcessManager(Environment, TaskManager.Token)); diff --git a/UnityProjects/UnityTools Package Project/Packages/manifest.json b/UnityProjects/UnityTools Package Project/Packages/manifest.json index 98b256a..b90042e 100644 --- a/UnityProjects/UnityTools Package Project/Packages/manifest.json +++ b/UnityProjects/UnityTools Package Project/Packages/manifest.json @@ -18,7 +18,7 @@ "dependencies": { "com.spoiledcat.environment": "1.0.22", "com.spoiledcat.logging": "1.0.22", - "com.spoiledcat.niceio": "1.0.22", + "com.spoiledcat.simpleio": "1.0.22", "com.spoiledcat.processmanager": "1.0.22", "com.spoiledcat.quick-console": "1.0.22", "com.spoiledcat.sharpziplib": "1.0.22", diff --git a/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/Asset.cs b/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/Asset.cs index 3c268c8..a75ec02 100644 --- a/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/Asset.cs +++ b/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/Asset.cs @@ -1,7 +1,7 @@ namespace LocalTools { using SpoiledCat.Json; - using SpoiledCat.NiceIO; + using SpoiledCat.SimpleIO; using SpoiledCat.Utilities; /// @@ -10,11 +10,11 @@ public struct Asset { private string hash; - private NPath path; + private SPath path; private UriString url; private bool needsUnzip; - public Asset(Asset asset, NPath localPath) + public Asset(Asset asset, SPath localPath) { hash = asset.hash; path = asset.path; @@ -25,10 +25,10 @@ public Asset(Asset asset, NPath localPath) } [NotSerialized] public UriString Url { get => url; set => url = value; } - [NotSerialized] public NPath Path { get => path; set => path = value; } + [NotSerialized] public SPath Path { get => path; set => path = value; } [NotSerialized] public string Hash { get => hash; set => hash = value; } [NotSerialized] public bool NeedsUnzip { get => needsUnzip; set => needsUnzip = value; } - [NotSerialized] public NPath LocalPath { get; set; } + [NotSerialized] public SPath LocalPath { get; set; } [NotSerialized] public string Filename => url?.Filename ?? ""; [NotSerialized] public bool NeedsDownload { get; set; } } diff --git a/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/Extensions.cs b/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/Extensions.cs index dca01c0..5c039ec 100644 --- a/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/Extensions.cs +++ b/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/Extensions.cs @@ -2,16 +2,16 @@ { using System; using System.Security.Cryptography; - using SpoiledCat.NiceIO; + using SpoiledCat.SimpleIO; public static class Extensions { - public static string ToMD5(this NPath path) + public static string ToMD5(this SPath path) { byte[] computeHash; using (var md5 = MD5.Create()) { - using (var stream = NPath.FileSystem.OpenRead(path.MakeAbsolute())) + using (var stream = SPath.FileSystem.OpenRead(path.MakeAbsolute())) { computeHash = md5.ComputeHash(stream); } diff --git a/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/Index.cs b/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/Index.cs index d668746..9400558 100644 --- a/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/Index.cs +++ b/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/Index.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using SpoiledCat.Json; - using SpoiledCat.NiceIO; + using SpoiledCat.SimpleIO; public struct Index { @@ -20,10 +20,10 @@ public Index(List assets) this.assets = assets; } - public static Index Load(NPath indexFile) => indexFile.ReadAllText().FromJson(true, false); - public static Index Load(string indexFile) => Load(indexFile.ToNPath()); + public static Index Load(SPath indexFile) => indexFile.ReadAllText().FromJson(true, false); + public static Index Load(string indexFile) => Load(indexFile.ToSPath()); - public void Save(NPath indexFile) => indexFile.WriteAllText(this.ToJson(true, false)); - public void Save(string indexFile) => Save(indexFile.ToNPath()); + public void Save(SPath indexFile) => indexFile.WriteAllText(this.ToJson(true, false)); + public void Save(string indexFile) => Save(indexFile.ToSPath()); } } diff --git a/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/LargeAssetManager.asmdef b/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/LargeAssetManager.asmdef index e8e5bf4..072643f 100644 --- a/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/LargeAssetManager.asmdef +++ b/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/LargeAssetManager.asmdef @@ -1,7 +1,7 @@ { "name": "LargeAssetManager", "references": [ - "com.spoiledcat.niceio", + "com.spoiledcat.simpleio", "com.spoiledcat.simplejson", "com.spoiledcat.logging", "com.spoiledcat.threading", diff --git a/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/LargeAssetManager.cs b/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/LargeAssetManager.cs index 46f3587..fd56d89 100644 --- a/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/LargeAssetManager.cs +++ b/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/LargeAssetManager.cs @@ -4,7 +4,7 @@ using LocalTools; using SpoiledCat.Json; using SpoiledCat.Logging; -using SpoiledCat.NiceIO; +using SpoiledCat.SimpleIO; using SpoiledCat.Threading; using SpoiledCat.Utilities; using UnityEditor; @@ -20,15 +20,15 @@ public class LargeAssetManager static LargeAssetManager() { - PocoJsonSerializerStrategy.RegisterCustomTypeHandler( - value => (((NPath)value).ToString(SlashMode.Forward), true), + PocoJsonSerializerStrategy.RegisterCustomTypeHandler( + value => (((SPath)value).ToString(SlashMode.Forward), true), (value, type) => { string str = value as string; if (!string.IsNullOrEmpty(str)) { - return (new NPath(str), true); + return (new SPath(str), true); } - return (NPath.Default, true); + return (SPath.Default, true); }); PocoJsonSerializerStrategy.RegisterCustomTypeHandler(value => (value.ToString(), true), @@ -66,7 +66,7 @@ private static void ClearProgress() } - public static void UpdateIndexFromFilesInFolder(NPath template, NPath indexPath, NPath path) + public static void UpdateIndexFromFilesInFolder(SPath template, SPath indexPath, SPath path) { var runTask = UpdateIndexFromFilesInFolderTask(path, indexPath, template); @@ -80,7 +80,7 @@ public static void UpdateIndexFromFilesInFolder(NPath template, NPath indexPath, .Start(); } - public static ITask UpdateIndexFromFilesInFolderTask(NPath folderWithFiles, NPath indexFileToGenerate, NPath? indexTemplate = null) + public static ITask UpdateIndexFromFilesInFolderTask(SPath folderWithFiles, SPath indexFileToGenerate, SPath? indexTemplate = null) { Index? templateIndex = null; if (indexTemplate.HasValue && indexTemplate.Value.FileExists()) @@ -105,7 +105,7 @@ public static ITask UpdateIndexFromFilesInFolderTask(NPath folderWithFiles, NPat else { asset.LocalPath = file; - asset.Path = file.FileNameWithoutExtension.ToNPath(); + asset.Path = file.FileNameWithoutExtension.ToSPath(); asset.NeedsUnzip = file.ExtensionWithDot == ".zip" ? true : false; asset.Url = $"{DefaultWebServerUrl}:{DefaultWebServerPort}/assets/{dt}/{file.FileName}"; } @@ -173,11 +173,11 @@ public static void JustUnzip() { var index = Index.Load("index.json"); - var downloads = "Downloads".ToNPath().MakeAbsolute(); + var downloads = "Downloads".ToSPath().MakeAbsolute(); List assetList = new List(); foreach (var asset in index.Assets.Where(x => x.NeedsUnzip)) { - NPath file = downloads.Combine(asset.Filename); + SPath file = downloads.Combine(asset.Filename); if (file.FileExists()) assetList.Add(new Asset(asset, downloads.Combine(asset.Filename))); } @@ -197,14 +197,14 @@ public static void JustUnzip() private static TaskQueue CalculateWhatNeedsToBeDownloaded(Index index) { - var downloads = "Downloads".ToNPath().MakeAbsolute(); + var downloads = "Downloads".ToSPath().MakeAbsolute(); List downloadList = new List(); TaskQueue t = new TaskQueue(TaskManager) { Message = "Calculating hashes..." }; foreach (var entry in index.Assets) { t.Queue(new FuncTask(TaskManager, (_, asset) => { - NPath file; + SPath file; if (asset.NeedsUnzip) { file = downloads.Combine(asset.Filename); @@ -261,9 +261,9 @@ public static ITask> DownloadIfNeeded(Index index) }); } - public static TaskQueue Unzip(List assetList) + public static TaskQueue Unzip(List assetList) { - var unzipper = new TaskQueue(TaskManager); + var unzipper = new TaskQueue(TaskManager); foreach (var asset in assetList.Where(x => x.NeedsUnzip)) { var unzipStamp = asset.LocalPath.Parent.Combine($".{asset.Filename}"); diff --git a/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/LargeAssetManagerWindow.cs b/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/LargeAssetManagerWindow.cs index 598ac9c..2c65421 100644 --- a/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/LargeAssetManagerWindow.cs +++ b/UnityProjects/UnityTools Source Project/Assets/Tools/LargeAssetManager/LargeAssetManagerWindow.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; using SpoiledCat.Logging; -using SpoiledCat.NiceIO; +using SpoiledCat.SimpleIO; using SpoiledCat.ProcessManager; using SpoiledCat.Threading; using SpoiledCat.UI; @@ -76,10 +76,10 @@ private void JustUnzip() private void CreateIndex() { LargeAssetManager.TaskManager = TaskManager; - string folder = EditorUtility.OpenFolderPanel("Select Folder with zip files to add to the index", "../../Helpers/Helper.WebServer/files/assets".ToNPath().Resolve(), ""); + string folder = EditorUtility.OpenFolderPanel("Select Folder with zip files to add to the index", "../../Helpers/Helper.WebServer/files/assets".ToSPath().Resolve(), ""); if (!string.IsNullOrEmpty(folder)) { - LargeAssetManager.UpdateIndexFromFilesInFolder("index-template.json".ToNPath(), "index.json".ToNPath(), folder.ToNPath()); + LargeAssetManager.UpdateIndexFromFilesInFolder("index-template.json".ToSPath(), "index.json".ToSPath(), folder.ToSPath()); } } @@ -114,7 +114,7 @@ public override void OnUI() if (GUILayout.Button("Start Web Server")) { webServerTask = new ProcessTaskLongRunning(TaskManager, ProcessEnvironment, - "Packages/com.spoiledcat.processmanager/Tests/Helpers~/Helper.CommandLine.exe".ToNPath().Resolve(), + "Packages/com.spoiledcat.processmanager/Tests/Helpers~/Helper.CommandLine.exe".ToSPath().Resolve(), $"-w -p {webServerPort}").Configure(new ProcessManager(Environment, TaskManager.Token)); diff --git a/UnityProjects/UnityTools Source Project/Packages/manifest.json b/UnityProjects/UnityTools Source Project/Packages/manifest.json index b64f324..37e91c0 100644 --- a/UnityProjects/UnityTools Source Project/Packages/manifest.json +++ b/UnityProjects/UnityTools Source Project/Packages/manifest.json @@ -2,7 +2,7 @@ "dependencies": { "com.spoiledcat.environment": "file:../../../../src/com.spoiledcat.environment", "com.spoiledcat.logging": "file:../../../../src/com.spoiledcat.logging", - "com.spoiledcat.niceio": "file:../../../../src/com.spoiledcat.niceio", + "com.spoiledcat.simpleio": "file:../../../../src/com.spoiledcat.simpleio", "com.spoiledcat.processmanager": "file:../../../../src/com.spoiledcat.processmanager", "com.spoiledcat.quick-console": "file:../../../../src/com.spoiledcat.quick-console", "com.spoiledcat.sharpziplib": "file:../../../../src/com.spoiledcat.sharpziplib", diff --git a/UnityTools.sln b/UnityTools.sln index dc732e7..1df1320 100644 --- a/UnityTools.sln +++ b/UnityTools.sln @@ -6,7 +6,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Environment", "src\com.spoi EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Logging", "src\com.spoiledcat.logging\Editor\SpoiledCat.Unity.Logging.csproj", "{AAE57A75-EC73-4C1A-9095-6B943AA15BC7}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NiceIO", "src\com.spoiledcat.niceio\Editor\SpoiledCat.Unity.NiceIO.csproj", "{BA3EC028-1970-4F51-95B5-2C18C7706924}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleIO", "src\com.spoiledcat.simpleio\Editor\SpoiledCat.Unity.SimpleIO.csproj", "{BA3EC028-1970-4F51-95B5-2C18C7706924}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleJson", "src\com.spoiledcat.simplejson\Editor\SpoiledCat.Unity.SimpleJson.csproj", "{2A572465-DE6D-42FA-BC88-C846D6931B5F}" EndProject diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 12ae6ec..9a5ee9e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -53,7 +53,7 @@ steps: # condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) # inputs: # command: 'publish' -# workingDir: 'build/packages/com.spoiledcat.niceio' +# workingDir: 'build/packages/com.spoiledcat.simpleio' # publishEndpoint: 'registry' # - task: Npm@1 diff --git a/common/packaging.targets b/common/packaging.targets index d3352d9..2cb9fc6 100644 --- a/common/packaging.targets +++ b/common/packaging.targets @@ -49,26 +49,22 @@ - - - - - @@ -76,7 +72,7 @@ - @@ -117,32 +113,28 @@ SkipUnchangedFiles="true" /> - + - - - - - diff --git a/extras/com.spoiledcat.processmanager/Tests/package.json b/extras/com.spoiledcat.processmanager/Tests/package.json index bbf9546..bdbc636 100644 --- a/extras/com.spoiledcat.processmanager/Tests/package.json +++ b/extras/com.spoiledcat.processmanager/Tests/package.json @@ -20,7 +20,7 @@ "dependencies": { "com.spoiledcat.environment": "0.0.0-placeholder", "com.spoiledcat.logging": "0.0.0-placeholder", - "com.spoiledcat.niceio": "0.0.0-placeholder", + "com.spoiledcat.simpleio": "0.0.0-placeholder", "com.spoiledcat.processmanager": "0.0.0-placeholder", "com.spoiledcat.threading": "0.0.0-placeholder", "com.spoiledcat.utilities": "0.0.0-placeholder" diff --git a/extras/com.spoiledcat.niceio/Editor/Version.cs.meta b/extras/com.spoiledcat.simpleio/Editor/Version.cs.meta similarity index 60% rename from extras/com.spoiledcat.niceio/Editor/Version.cs.meta rename to extras/com.spoiledcat.simpleio/Editor/Version.cs.meta index d716956..b48c230 100644 --- a/extras/com.spoiledcat.niceio/Editor/Version.cs.meta +++ b/extras/com.spoiledcat.simpleio/Editor/Version.cs.meta @@ -1,11 +1,11 @@ fileFormatVersion: 2 -guid: fceb56fcd400be348b66139e5b881846 +guid: 51b4035db7f44e4abbb99b96166e026a MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: + userData: + assetBundleName: + assetBundleVariant: diff --git a/extras/com.spoiledcat.threading/Tests/package.json b/extras/com.spoiledcat.threading/Tests/package.json index 1a402e5..fa1e690 100644 --- a/extras/com.spoiledcat.threading/Tests/package.json +++ b/extras/com.spoiledcat.threading/Tests/package.json @@ -21,7 +21,7 @@ "com.spoiledcat.threading": "0.0.0-placeholder", "com.spoiledcat.logging": "0.0.0-placeholder", "com.spoiledcat.utilities": "0.0.0-placeholder", - "com.spoiledcat.niceio": "0.0.0-placeholder", + "com.spoiledcat.simpleio": "0.0.0-placeholder", "com.spoiledcat.threading.tasks": "0.0.0-placeholder" } } \ No newline at end of file diff --git a/pack.sh b/pack.sh index e3c9e7d..71123bb 100755 --- a/pack.sh +++ b/pack.sh @@ -10,6 +10,7 @@ fi CONFIGURATION="" PUBLIC="" +BUILD=0 while (( "$#" )); do case "$1" in @@ -25,6 +26,10 @@ while (( "$#" )); do PUBLIC="/p:PublicRelease=true" shift ;; + -b|--build) + BUILD=1 + shift + ;; -*|--*=) # unsupported flags echo "Error: Unsupported flag $1" >&2 exit 1 @@ -48,6 +53,23 @@ if [[ x"$OS" == x"Windows" && x"$PUBLIC" != x"" ]]; then PUBLIC="/$PUBLIC" fi +NPMDIR="$DIR/build/npm/" +PACKAGEDIR="$DIR/build/packages" + pushd $DIR + +if [[ x"$BUILD" == x"1" ]]; then + dotnet restore + dotnet build --no-restore -c $CONFIGURATION $PUBLIC +fi dotnet pack --no-build --no-restore -c $CONFIGURATION $PUBLIC + +mkdir -p "$NPMDIR" +for j in $PACKAGEDIR/*; do + pushd "$j" + npm pack + mv *.tgz "$NPMDIR" + popd +done + popd \ No newline at end of file diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 94cd7f9..b1e4de4 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -27,7 +27,7 @@ - + diff --git a/src/GitInstaller/GitEnvironment.cs b/src/GitInstaller/GitEnvironment.cs index b3be02c..7b00f02 100644 --- a/src/GitInstaller/GitEnvironment.cs +++ b/src/GitInstaller/GitEnvironment.cs @@ -1,30 +1,30 @@ namespace SpoiledCat.Git { - using NiceIO; + using SimpleIO; using Unity; public interface IGitEnvironment : IEnvironment { - NPath GitInstallationPath { get; } - NPath GitExecutablePath { get; } - NPath GitLfsInstallationPath { get; } - NPath GitLfsExecutablePath { get; } + SPath GitInstallationPath { get; } + SPath GitExecutablePath { get; } + SPath GitLfsInstallationPath { get; } + SPath GitLfsExecutablePath { get; } void Resolve(GitInstaller.GitInstallationState defaults); } public class GitEnvironment : UnityEnvironment, IGitEnvironment { - public NPath GitInstallationPath { get; private set; } - public NPath GitExecutablePath { get; private set; } - public NPath GitLfsInstallationPath { get; private set; } - public NPath GitLfsExecutablePath { get; private set; } + public SPath GitInstallationPath { get; private set; } + public SPath GitExecutablePath { get; private set; } + public SPath GitLfsInstallationPath { get; private set; } + public SPath GitLfsExecutablePath { get; private set; } public GitEnvironment(string applicationName, string logFile) : base(applicationName, logFile) { } - public override void Initialize(string unityVersion, NPath extensionInstallPath, NPath EditorApplication_applicationPath, NPath EditorApplication_applicationContentsPath, NPath Application_dataPath) + public override void Initialize(string unityVersion, SPath extensionInstallPath, SPath EditorApplication_applicationPath, SPath EditorApplication_applicationContentsPath, SPath Application_dataPath) { base.Initialize(unityVersion, extensionInstallPath, EditorApplication_applicationPath, EditorApplication_applicationContentsPath, Application_dataPath); Resolve(new GitInstaller.GitInstallationState(new GitInstaller.GitInstallDetails(UserCachePath, this))); @@ -33,24 +33,24 @@ public override void Initialize(string unityVersion, NPath extensionInstallPath, public void Resolve(GitInstaller.GitInstallationState state) { - if (ResolvePaths("git", state.GitExecutablePath, out NPath gitExecPath, out NPath gitInstallPath)) + if (ResolvePaths("git", state.GitExecutablePath, out SPath gitExecPath, out SPath gitInstallPath)) { GitExecutablePath = gitExecPath; GitInstallationPath = gitInstallPath; } else - GitExecutablePath = GitInstallationPath = NPath.Default; + GitExecutablePath = GitInstallationPath = SPath.Default; - if (GitInstallationPath != state.GitInstallationPath && ResolvePaths("git-lfs", state.GitLfsExecutablePath, out NPath gitLfsExecPath, out NPath gitLfsInstallPath)) { + if (GitInstallationPath != state.GitInstallationPath && ResolvePaths("git-lfs", state.GitLfsExecutablePath, out SPath gitLfsExecPath, out SPath gitLfsInstallPath)) { GitLfsExecutablePath = gitLfsExecPath; GitLfsInstallationPath = gitLfsExecPath; } else - GitLfsExecutablePath = GitLfsInstallationPath = NPath.Default; + GitLfsExecutablePath = GitLfsInstallationPath = SPath.Default; } - private bool ResolvePaths(string execName, NPath pathToExecutable, out NPath execPath, out NPath installPath) + private bool ResolvePaths(string execName, SPath pathToExecutable, out SPath execPath, out SPath installPath) { - execPath = installPath = NPath.Default; + execPath = installPath = SPath.Default; if (pathToExecutable.DirectoryExists()) pathToExecutable = pathToExecutable.Combine(execName + ExecutableExtension); diff --git a/src/GitInstaller/GitInstaller.asmdef b/src/GitInstaller/GitInstaller.asmdef index 86f1dff..6428c69 100644 --- a/src/GitInstaller/GitInstaller.asmdef +++ b/src/GitInstaller/GitInstaller.asmdef @@ -1,7 +1,7 @@ { "name": "GitInstaller", "references": [ - "NiceIO", + "SimpleIO", "NiceThreading", "SimpleLogging", "Utilities", diff --git a/src/GitInstaller/GitInstaller.cs b/src/GitInstaller/GitInstaller.cs index b049dad..bc59663 100644 --- a/src/GitInstaller/GitInstaller.cs +++ b/src/GitInstaller/GitInstaller.cs @@ -4,7 +4,7 @@ namespace SpoiledCat.Git { using Logging; - using NiceIO; + using SimpleIO; using Threading; using Utilities; using ProcessManager; @@ -340,7 +340,7 @@ private GitInstallationState GrabZipFromResourcesIfNeeded(GitInstallationState s public GitInstallationState ExtractGit(GitInstallationState state) { - var tempZipExtractPath = NPath.CreateTempDirectory("git_zip_extract_zip_paths"); + var tempZipExtractPath = SPath.CreateTempDirectory("git_zip_extract_zip_paths"); if (state.GitZipExists && !state.GitIsValid) { @@ -378,10 +378,10 @@ public class GitInstallationState public bool GitIsValid { get; set; } public bool GitLfsIsValid { get; set; } public bool GitZipExists { get; set; } - public NPath GitInstallationPath { get; set; } - public NPath GitExecutablePath { get; set; } - public NPath GitLfsInstallationPath { get; set; } - public NPath GitLfsExecutablePath { get; set; } + public SPath GitInstallationPath { get; set; } + public SPath GitExecutablePath { get; set; } + public SPath GitLfsInstallationPath { get; set; } + public SPath GitLfsExecutablePath { get; set; } public DateTimeOffset GitLastCheckTime { get; set; } public bool IsCustomGitPath { get; set; } public TheVersion GitVersion { get; set; } @@ -416,7 +416,7 @@ public class GitInstallDetails public const string GitDirectory = "git"; - public GitInstallDetails(NPath baseDataPath, IEnvironment environment) + public GitInstallDetails(SPath baseDataPath, IEnvironment environment) { ZipPath = baseDataPath.Combine("downloads"); ZipPath.EnsureDirectoryExists(); @@ -424,15 +424,15 @@ public GitInstallDetails(NPath baseDataPath, IEnvironment environment) GitInstallationPath = baseDataPath.Combine(GitDirectory); GitExecutablePath = GitInstallationPath.Combine(environment.IsWindows ? "cmd" : "bin", "git" + UnityEnvironment.ExecutableExtension); //GitLfsExecutablePath = GitExecutablePath.Parent.Combine("git-lfs" + UnityEnvironment.ExecutableExtension); - GitLfsExecutablePath = NPath.Default; + GitLfsExecutablePath = SPath.Default; GitPackageFeed = packageFeed; } - public NPath ZipPath { get; } - public NPath GitZipPath { get; set; } - public NPath GitInstallationPath { get; } - public NPath GitExecutablePath { get; } - public NPath GitLfsExecutablePath { get; } + public SPath ZipPath { get; } + public SPath GitZipPath { get; set; } + public SPath GitInstallationPath { get; } + public SPath GitExecutablePath { get; } + public SPath GitLfsExecutablePath { get; } public UriString GitPackageFeed { get; set; } } } diff --git a/src/GitInstaller/GitProcessEnvironment.cs b/src/GitInstaller/GitProcessEnvironment.cs index a47eb1a..938a0ca 100644 --- a/src/GitInstaller/GitProcessEnvironment.cs +++ b/src/GitInstaller/GitProcessEnvironment.cs @@ -4,19 +4,19 @@ namespace SpoiledCat.Git { - using NiceIO; + using SimpleIO; using ProcessManager; public class GitProcessEnvironment : ProcessEnvironment { public static IProcessEnvironment Instance { get; private set; } public new IGitEnvironment Environment => base.Environment as IGitEnvironment; - private NPath basePath; - private NPath gitBinary; - private NPath libExecPath; + private SPath basePath; + private SPath gitBinary; + private SPath libExecPath; private string[] envPath; - public GitProcessEnvironment(IGitEnvironment environment, NPath repositoryRoot) + public GitProcessEnvironment(IGitEnvironment environment, SPath repositoryRoot) : base(environment, FindRepositoryRoot(repositoryRoot)) { Instance = this; @@ -25,7 +25,7 @@ public GitProcessEnvironment(IGitEnvironment environment, NPath repositoryRoot) public void Reset(GitInstaller.GitInstallationState state = null) { - basePath = gitBinary = libExecPath = NPath.Default; + basePath = gitBinary = libExecPath = SPath.Default; envPath = null; if (!Environment.GitInstallationPath.IsInitialized && !((state?.GitInstallationPath.IsInitialized) ?? false)) @@ -36,21 +36,21 @@ public void Reset(GitInstaller.GitInstallationState state = null) basePath = ResolveBasePath(); envPath = CreateEnvPath().ToArray(); - if (ResolveGitExecPath(out NPath p)) + if (ResolveGitExecPath(out SPath p)) libExecPath = p; } - private static NPath FindRepositoryRoot(NPath repositoryRoot) + private static SPath FindRepositoryRoot(SPath repositoryRoot) { if (repositoryRoot.IsInitialized) return repositoryRoot; - var ret = NPath.CurrentDirectory.RecursiveParents.FirstOrDefault(d => d.Exists(".git")); + var ret = SPath.CurrentDirectory.RecursiveParents.FirstOrDefault(d => d.Exists(".git")); if (ret.IsInitialized) return ret; - return NPath.CurrentDirectory; + return SPath.CurrentDirectory; } - public override void Configure(ProcessStartInfo psi, NPath? workingDirectory = null) + public override void Configure(ProcessStartInfo psi, SPath? workingDirectory = null) { base.Configure(psi, workingDirectory); @@ -104,13 +104,13 @@ public override void Configure(ProcessStartInfo psi, NPath? workingDirectory = n } - public bool ResolveGitExecPath(out NPath path) + public bool ResolveGitExecPath(out SPath path) { path = ResolveBasePath().Combine("libexec", "git-core"); return path.DirectoryExists(); } - private NPath ResolveBasePath() + private SPath ResolveBasePath() { var path = Environment.GitInstallationPath; if (Environment.IsWindows) diff --git a/src/GitInstaller/GitReleaseManifest.cs b/src/GitInstaller/GitReleaseManifest.cs index dc04a08..25231c8 100644 --- a/src/GitInstaller/GitReleaseManifest.cs +++ b/src/GitInstaller/GitReleaseManifest.cs @@ -8,7 +8,7 @@ namespace SpoiledCat.Git { using Json; using Logging; - using NiceIO; + using SimpleIO; using Threading; using Unity; using Utilities; @@ -62,7 +62,7 @@ public struct Asset return (assets.FirstOrDefault(x => x.Name.EndsWith(name)), assets.FirstOrDefault(x => x.Name.EndsWith(name + ".sha256"))); } - public static DugiteReleaseManifest Load(NPath path, IEnvironment environment) + public static DugiteReleaseManifest Load(SPath path, IEnvironment environment) { var manifest = path.ReadAllText().FromJson(true, false); var (zipAsset, shaAsset) = manifest.GetAsset(environment); @@ -78,10 +78,10 @@ public static DugiteReleaseManifest Load(NPath path, IEnvironment environment) return manifest; } - public static DugiteReleaseManifest Load(NPath localCacheFile, UriString packageFeed, IEnvironment environment) + public static DugiteReleaseManifest Load(SPath localCacheFile, UriString packageFeed, IEnvironment environment) { DugiteReleaseManifest package = null; - //NPath localCacheFeed = environment.UserCachePath.Combine("embedded-git.json"); + //SPath localCacheFeed = environment.UserCachePath.Combine("embedded-git.json"); var filename = localCacheFile.FileName; var key = localCacheFile.FileNameWithoutExtension + "_updatelastCheckTime"; var now = DateTimeOffset.Now; diff --git a/src/com.spoiledcat.environment/Editor/Settings.cs b/src/com.spoiledcat.environment/Editor/Settings.cs index a909734..1447255 100644 --- a/src/com.spoiledcat.environment/Editor/Settings.cs +++ b/src/com.spoiledcat.environment/Editor/Settings.cs @@ -12,7 +12,7 @@ namespace SpoiledCat.Unity { using Json; using Logging; - using NiceIO; + using SimpleIO; public interface ISettings { @@ -23,7 +23,7 @@ public interface ISettings void Set(string key, T value); void Unset(string key); void Rename(string oldKey, string newKey); - NPath SettingsPath { get; set; } + SPath SettingsPath { get; set; } } public abstract class BaseSettings : ISettings @@ -35,7 +35,7 @@ public abstract class BaseSettings : ISettings public abstract void Rename(string oldKey, string newKey); public abstract void Set(string key, T value); public abstract void Unset(string key); - public NPath SettingsPath { get; set; } + public SPath SettingsPath { get; set; } protected virtual string SettingsFileName { get; set; } } @@ -161,7 +161,7 @@ protected virtual void LoadFromCache(string path) { EnsureCachePath(path); - var npath = path.ToNPath(); + var npath = path.ToSPath(); if (!npath.FileExists()) { cacheData = new Dictionary(); @@ -192,7 +192,7 @@ protected virtual bool SaveToCache(string path) { EnsureCachePath(path); - var npath = path.ToNPath(); + var npath = path.ToSPath(); try { var data = cacheData.ToJson(); @@ -209,7 +209,7 @@ protected virtual bool SaveToCache(string path) private void EnsureCachePath(string path) { - var npath = path.ToNPath(); + var npath = path.ToSPath(); if (npath.FileExists()) return; npath.EnsureParentDirectoryExists(); diff --git a/src/com.spoiledcat.environment/Editor/SpoiledCat.Unity.Environment.csproj b/src/com.spoiledcat.environment/Editor/SpoiledCat.Unity.Environment.csproj index 54104e5..8ee345e 100644 --- a/src/com.spoiledcat.environment/Editor/SpoiledCat.Unity.Environment.csproj +++ b/src/com.spoiledcat.environment/Editor/SpoiledCat.Unity.Environment.csproj @@ -8,7 +8,7 @@ - + diff --git a/src/com.spoiledcat.environment/Editor/TheEnvironment.cs b/src/com.spoiledcat.environment/Editor/TheEnvironment.cs index e4816b1..6ddb9bd 100644 --- a/src/com.spoiledcat.environment/Editor/TheEnvironment.cs +++ b/src/com.spoiledcat.environment/Editor/TheEnvironment.cs @@ -11,7 +11,7 @@ namespace SpoiledCat.Unity { - using NiceIO; + using SimpleIO; public sealed class TheEnvironment : ScriptableSingleton { @@ -34,17 +34,17 @@ public void Flush() Save(true); } - private NPath DetermineInstallationPath() + private SPath DetermineInstallationPath() { #if UNITY_EDITOR // Juggling to find out where we got installed var shim = CreateInstance(); var script = MonoScript.FromScriptableObject(shim); - var scriptPath = Application.dataPath.ToNPath().Parent.Combine(AssetDatabase.GetAssetPath(script).ToNPath()); + var scriptPath = Application.dataPath.ToSPath().Parent.Combine(AssetDatabase.GetAssetPath(script).ToSPath()); DestroyImmediate(shim); return scriptPath.Parent; #else - return Application.dataPath.ToNPath(); + return Application.dataPath.ToSPath(); #endif } @@ -69,12 +69,12 @@ public IEnvironment Environment } environment.Initialize( - unityAssetsPath.ToNPath(), extensionInstallPath.ToNPath() + unityAssetsPath.ToSPath(), extensionInstallPath.ToSPath() #if UNITY_EDITOR , unityVersion, - unityApplication.ToNPath(), - unityApplicationContents.ToNPath() + unityApplication.ToSPath(), + unityApplicationContents.ToSPath() #endif ); Flush(); diff --git a/src/com.spoiledcat.environment/Editor/UnityEnvironment.cs b/src/com.spoiledcat.environment/Editor/UnityEnvironment.cs index 5e41048..84eff76 100644 --- a/src/com.spoiledcat.environment/Editor/UnityEnvironment.cs +++ b/src/com.spoiledcat.environment/Editor/UnityEnvironment.cs @@ -11,19 +11,19 @@ namespace SpoiledCat.Extensions { - using NiceIO; + using SimpleIO; using Unity; public static class EnvironmentExtensions { - public static IEnumerable ToNPathList(this IEnvironment environment, string envPath) + public static IEnumerable ToSPathList(this IEnvironment environment, string envPath) { return envPath .Split(Path.PathSeparator) .Where(x => x != null) .Select(x => environment.ExpandEnvironmentVariables(x.Trim('"', '\''))) .Where(x => !String.IsNullOrEmpty(x)) - .Select(x => x.ToNPath()); + .Select(x => x.ToSPath()); } } } @@ -31,11 +31,11 @@ public static IEnumerable ToNPathList(this IEnvironment environment, stri namespace SpoiledCat.Unity { using Logging; - using NiceIO; + using SimpleIO; public interface IEnvironment { - IEnvironment Initialize(NPath assetsPath, NPath extensionInstallPath, string unityVersion = null, NPath unityApplicationPath = default, NPath unityApplicationContentsPath = default); + IEnvironment Initialize(SPath assetsPath, SPath extensionInstallPath, string unityVersion = null, SPath unityApplicationPath = default, SPath unityApplicationContentsPath = default); string ExpandEnvironmentVariables(string name); string GetEnvironmentVariable(string v); string GetSpecialFolder(Environment.SpecialFolder folder); @@ -48,19 +48,19 @@ public interface IEnvironment bool IsMac { get; } bool Is32Bit { get; } string UnityVersion { get; } - NPath UnityApplication { get; } - NPath UnityApplicationContents { get; } - NPath UnityAssetsPath { get; } - NPath UnityProjectPath { get; } - NPath ExtensionInstallPath { get; } - NPath UserCachePath { get; set; } - NPath SystemCachePath { get; set; } - NPath LogPath { get; } + SPath UnityApplication { get; } + SPath UnityApplicationContents { get; } + SPath UnityAssetsPath { get; } + SPath UnityProjectPath { get; } + SPath ExtensionInstallPath { get; } + SPath UserCachePath { get; set; } + SPath SystemCachePath { get; set; } + SPath LogPath { get; } ISettings LocalSettings { get; } ISettings SystemSettings { get; } ISettings UserSettings { get; } string ApplicationName { get; } - NPath WorkingDirectory { get; } + SPath WorkingDirectory { get; } } public class UnityEnvironment : IEnvironment @@ -75,19 +75,19 @@ public UnityEnvironment(string applicationName, string logFile = DefaultLogFilen { ApplicationName = applicationName; - UserCachePath = NPath.LocalAppData.Combine(applicationName); - SystemCachePath = NPath.CommonAppData.Combine(applicationName); - LogPath = IsMac ? NPath.HomeDirectory.Combine("Library/Logs").Combine(applicationName) : UserCachePath; + UserCachePath = SPath.LocalAppData.Combine(applicationName); + SystemCachePath = SPath.CommonAppData.Combine(applicationName); + LogPath = IsMac ? SPath.HomeDirectory.Combine("Library/Logs").Combine(applicationName) : UserCachePath; LogPath = LogPath.Combine(logFile); LogPath.EnsureParentDirectoryExists(); } public virtual IEnvironment Initialize( - NPath Application_dataPath, - NPath extensionInstallPath, + SPath Application_dataPath, + SPath extensionInstallPath, string unityVersion = null, - NPath EditorApplication_applicationPath = default, - NPath EditorApplication_applicationContentsPath = default + SPath EditorApplication_applicationPath = default, + SPath EditorApplication_applicationContentsPath = default ) { ExtensionInstallPath = extensionInstallPath; @@ -99,17 +99,17 @@ public virtual IEnvironment Initialize( UserSettings = new UserSettings(this); LocalSettings = new LocalSettings(this); SystemSettings = new SystemSettings(this); - WorkingDirectory = NPath.CurrentDirectory; + WorkingDirectory = SPath.CurrentDirectory; return this; } - public void SetWorkingDirectory(NPath workingDirectory) + public void SetWorkingDirectory(SPath workingDirectory) { WorkingDirectory = workingDirectory; } - public string GetSpecialFolder(Environment.SpecialFolder folder) => NPath.FileSystem.GetFolderPath(folder); + public string GetSpecialFolder(Environment.SpecialFolder folder) => SPath.FileSystem.GetFolderPath(folder); public string ExpandEnvironmentVariables(string name) { @@ -135,16 +135,16 @@ private static string GetEnvironmentVariableKeyInternal(string name) } public string ApplicationName { get; } - public NPath LogPath { get; } + public SPath LogPath { get; } public string UnityVersion { get; set; } - public NPath UnityApplication { get; set; } - public NPath UnityApplicationContents { get; set; } - public NPath UnityAssetsPath { get; set; } - public NPath UnityProjectPath { get; set; } - public NPath ExtensionInstallPath { get; set; } - public NPath UserCachePath { get; set; } - public NPath SystemCachePath { get; set; } - public NPath WorkingDirectory { get; private set; } + public SPath UnityApplication { get; set; } + public SPath UnityApplicationContents { get; set; } + public SPath UnityAssetsPath { get; set; } + public SPath UnityProjectPath { get; set; } + public SPath ExtensionInstallPath { get; set; } + public SPath UserCachePath { get; set; } + public SPath SystemCachePath { get; set; } + public SPath WorkingDirectory { get; private set; } public string Path { get; set; } = Environment.GetEnvironmentVariable(GetEnvironmentVariableKeyInternal("PATH")); @@ -159,10 +159,10 @@ private static string GetEnvironmentVariableKeyInternal(string name) public bool IsMac => OnMac; public bool Is32Bit => IntPtr.Size == 4; - public static bool OnWindows => NPath.IsWindows; + public static bool OnWindows => SPath.IsWindows; - public static bool OnLinux => NPath.IsLinux; - public static bool OnMac => NPath.IsMac; + public static bool OnLinux => SPath.IsLinux; + public static bool OnMac => SPath.IsMac; public static string ExecutableExtension => OnWindows ? ".exe" : string.Empty; public static ILogging Logger { get; } = LogHelper.GetLogger(); diff --git a/src/com.spoiledcat.environment/Editor/com.spoiledcat.environment.asmdef b/src/com.spoiledcat.environment/Editor/com.spoiledcat.environment.asmdef index 329781e..824f2a5 100644 --- a/src/com.spoiledcat.environment/Editor/com.spoiledcat.environment.asmdef +++ b/src/com.spoiledcat.environment/Editor/com.spoiledcat.environment.asmdef @@ -1,7 +1,7 @@ { "name": "com.spoiledcat.environment", "references": [ - "com.spoiledcat.niceio", + "com.spoiledcat.simpleio", "com.spoiledcat.logging", "com.spoiledcat.simplejson" ], diff --git a/src/com.spoiledcat.niceio/Editor.meta b/src/com.spoiledcat.niceio/Editor.meta deleted file mode 100644 index 354ce83..0000000 --- a/src/com.spoiledcat.niceio/Editor.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 6bd1603781c94a64ab79ea709aae5096 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/com.spoiledcat.niceio/Editor/SpoiledCat.Unity.NiceIO.csproj.meta b/src/com.spoiledcat.niceio/Editor/SpoiledCat.Unity.NiceIO.csproj.meta deleted file mode 100644 index b8ea91b..0000000 --- a/src/com.spoiledcat.niceio/Editor/SpoiledCat.Unity.NiceIO.csproj.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 96e0524a54b21ff4983cd10bc607da90 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/com.spoiledcat.niceio/Editor/com.spoiledcat.niceio.asmdef.meta b/src/com.spoiledcat.niceio/Editor/com.spoiledcat.niceio.asmdef.meta deleted file mode 100644 index 99c8fb4..0000000 --- a/src/com.spoiledcat.niceio/Editor/com.spoiledcat.niceio.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: cf4e027c83f63f645b34401d5b257da8 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/com.spoiledcat.niceio/LICENSE.meta b/src/com.spoiledcat.niceio/LICENSE.meta deleted file mode 100644 index 36ce421..0000000 --- a/src/com.spoiledcat.niceio/LICENSE.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 17063034220a61b4595598a2aebf29af -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/com.spoiledcat.niceio/package.json.meta b/src/com.spoiledcat.niceio/package.json.meta deleted file mode 100644 index f1b3101..0000000 --- a/src/com.spoiledcat.niceio/package.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: eb66f4eaaed35694e8dcca3949dbeb41 -PackageManifestImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/com.spoiledcat.niceio/version.json.meta b/src/com.spoiledcat.niceio/version.json.meta deleted file mode 100644 index d53935b..0000000 --- a/src/com.spoiledcat.niceio/version.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 255fb0646d7084543b76cc39112450d5 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/com.spoiledcat.processmanager/Editor/FindExecTask.cs b/src/com.spoiledcat.processmanager/Editor/FindExecTask.cs index 059809b..527379b 100644 --- a/src/com.spoiledcat.processmanager/Editor/FindExecTask.cs +++ b/src/com.spoiledcat.processmanager/Editor/FindExecTask.cs @@ -1,17 +1,17 @@ namespace SpoiledCat.ProcessManager { - using NiceIO; + using SimpleIO; using Threading; using Unity; - public class FindExecTask : SimpleProcessTask + public class FindExecTask : SimpleProcessTask { public FindExecTask(ITaskManager taskManager, IProcessManager processManager, string execToFind, IEnvironment environment) : base(taskManager, processManager, environment.IsWindows ? "where" : "which", execToFind, - new FirstNonNullLineOutputProcessor(line => new NPath(line))) + new FirstNonNullLineOutputProcessor(line => new SPath(line))) { processManager.Configure(this); } diff --git a/src/com.spoiledcat.processmanager/Editor/IProcessManager.cs b/src/com.spoiledcat.processmanager/Editor/IProcessManager.cs index 3a23a35..94323c2 100644 --- a/src/com.spoiledcat.processmanager/Editor/IProcessManager.cs +++ b/src/com.spoiledcat.processmanager/Editor/IProcessManager.cs @@ -5,7 +5,7 @@ namespace SpoiledCat.ProcessManager { - using NiceIO; + using SimpleIO; public interface IProcess { @@ -26,12 +26,12 @@ public interface IProcess public interface IProcessManager { T Configure(T processTask, - NPath? workingDirectory = null, + SPath? workingDirectory = null, bool withInput = false) where T : IProcessTask; IProcess Reconnect(IProcess processTask, int i); - void RunCommandLineWindow(NPath workingDirectory); + void RunCommandLineWindow(SPath workingDirectory); void Stop(); CancellationToken CancellationToken { get; } IProcessEnvironment DefaultProcessEnvironment { get; } diff --git a/src/com.spoiledcat.processmanager/Editor/PremadeTasks.cs b/src/com.spoiledcat.processmanager/Editor/PremadeTasks.cs index 68854d2..026871f 100644 --- a/src/com.spoiledcat.processmanager/Editor/PremadeTasks.cs +++ b/src/com.spoiledcat.processmanager/Editor/PremadeTasks.cs @@ -6,7 +6,7 @@ namespace SpoiledCat.ProcessManager { - using NiceIO; + using SimpleIO; using System; using System.Collections.Generic; using Threading; @@ -14,7 +14,7 @@ namespace SpoiledCat.ProcessManager public class SimpleProcessTask : ProcessTask { public SimpleProcessTask(ITaskManager taskManager, IProcessManager processManager, - string executable, string arguments, NPath? workingDirectory = null, + string executable, string arguments, SPath? workingDirectory = null, IOutputProcessor processor = null) : base(taskManager, processManager.DefaultProcessEnvironment, executable, arguments, processor ?? new SimpleOutputProcessor()) @@ -29,7 +29,7 @@ public SimpleProcessTask( ITaskManager taskManager, IProcessManager processManager, string executable, string arguments, Func processor, - NPath? workingDirectory = null + SPath? workingDirectory = null ) : base(taskManager, taskManager?.Token ?? default, processManager.DefaultProcessEnvironment, @@ -49,7 +49,7 @@ public SimpleProcessTask( ITaskManager taskManager, IProcessManager processManager, string executable, string arguments, IOutputProcessor outputProcessor, - NPath? workingDirectory = null + SPath? workingDirectory = null ) : base(taskManager, taskManager?.Token ?? default, processManager.DefaultProcessEnvironment, @@ -63,7 +63,7 @@ public class SimpleListProcessTask : ProcessTaskWithListOutput { public SimpleListProcessTask( ITaskManager taskManager, IProcessManager processManager, - string executable, string arguments, NPath? workingDirectory = null, + string executable, string arguments, SPath? workingDirectory = null, IOutputProcessor> processor = null ) : base(taskManager, taskManager?.Token ?? default, @@ -78,7 +78,7 @@ public SimpleListProcessTask( public class FirstNonNullLineProcessTask : SimpleProcessTask { public FirstNonNullLineProcessTask(ITaskManager taskManager, IProcessManager processManager, - string executable, string arguments, NPath? workingDirectory = null) + string executable, string arguments, SPath? workingDirectory = null) : base(taskManager, processManager, executable, arguments, workingDirectory, new FirstNonNullLineOutputProcessor()) { diff --git a/src/com.spoiledcat.processmanager/Editor/ProcessEnvironment.cs b/src/com.spoiledcat.processmanager/Editor/ProcessEnvironment.cs index e054bd9..7a4f78e 100644 --- a/src/com.spoiledcat.processmanager/Editor/ProcessEnvironment.cs +++ b/src/com.spoiledcat.processmanager/Editor/ProcessEnvironment.cs @@ -8,12 +8,12 @@ namespace SpoiledCat.ProcessManager { using Logging; - using NiceIO; + using SimpleIO; using Unity; public interface IProcessEnvironment { - void Configure(ProcessStartInfo psi, NPath? workingDirectory = null); + void Configure(ProcessStartInfo psi, SPath? workingDirectory = null); IEnvironment Environment { get; } } @@ -25,14 +25,14 @@ public ProcessEnvironment(IEnvironment environment) Environment = environment; } - public virtual void Configure(ProcessStartInfo psi, NPath? workingDirectory = null) + public virtual void Configure(ProcessStartInfo psi, SPath? workingDirectory = null) { Guard.ArgumentNotNull(psi, "psi"); workingDirectory = workingDirectory ?? Environment.WorkingDirectory; psi.WorkingDirectory = workingDirectory; - psi.EnvironmentVariables["HOME"] = NPath.HomeDirectory; - psi.EnvironmentVariables["TMP"] = psi.EnvironmentVariables["TEMP"] = NPath.SystemTemp; + psi.EnvironmentVariables["HOME"] = SPath.HomeDirectory; + psi.EnvironmentVariables["TMP"] = psi.EnvironmentVariables["TEMP"] = SPath.SystemTemp; var path = Environment.Path; psi.EnvironmentVariables["PROCESS_WORKINGDIR"] = workingDirectory; diff --git a/src/com.spoiledcat.processmanager/Editor/ProcessManager.cs b/src/com.spoiledcat.processmanager/Editor/ProcessManager.cs index 8afd677..9a24aa8 100644 --- a/src/com.spoiledcat.processmanager/Editor/ProcessManager.cs +++ b/src/com.spoiledcat.processmanager/Editor/ProcessManager.cs @@ -12,7 +12,7 @@ namespace SpoiledCat.ProcessManager { using Logging; - using NiceIO; + using SimpleIO; using Unity; public class ProcessManager : IProcessManager @@ -31,7 +31,7 @@ public ProcessManager(IEnvironment environment, CancellationToken = cancellationToken; } - public static NPath FindExecutableInPath(string executable, bool recurse = false, params NPath[] searchPaths) + public static SPath FindExecutableInPath(string executable, bool recurse = false, params SPath[] searchPaths) { Guard.ArgumentNotNullOrWhiteSpace(executable, "executable"); @@ -42,7 +42,7 @@ public static NPath FindExecutableInPath(string executable, bool recurse = false } public T Configure(T processTask, - NPath? workingDirectory = null, + SPath? workingDirectory = null, bool withInput = false) where T : IProcessTask { @@ -69,7 +69,7 @@ public T Configure(T processTask, return processTask; } - public void RunCommandLineWindow(NPath workingDirectory) + public void RunCommandLineWindow(SPath workingDirectory) { var startInfo = new ProcessStartInfo { @@ -90,7 +90,7 @@ public void RunCommandLineWindow(NPath workingDirectory) // we need to create a temp bash script to set up the environment properly, because // osx terminal app doesn't inherit the PATH env var and there's no way to pass it in - var envVarFile = NPath.GetTempFilename(); + var envVarFile = SPath.GetTempFilename(); startInfo.FileName = "open"; startInfo.Arguments = $"-a Terminal {envVarFile}"; startInfo.Configure(DefaultProcessEnvironment, workingDirectory); diff --git a/src/com.spoiledcat.processmanager/Editor/ProcessTask.cs b/src/com.spoiledcat.processmanager/Editor/ProcessTask.cs index 8b21adf..2e9195e 100644 --- a/src/com.spoiledcat.processmanager/Editor/ProcessTask.cs +++ b/src/com.spoiledcat.processmanager/Editor/ProcessTask.cs @@ -14,21 +14,21 @@ namespace SpoiledCat.ProcessManager { using Logging; - using NiceIO; + using SimpleIO; using Threading; using Extensions; public static class ProcessTaskExtensions { public static T Configure(this T task, IProcessManager processManager, - NPath? workingDirectory = null, + SPath? workingDirectory = null, bool withInput = false) where T : IProcessTask { return processManager.Configure(task, workingDirectory, withInput); } - public static void Configure(this ProcessStartInfo psi, IProcessEnvironment processEnvironment, NPath? workingDirectory = null) + public static void Configure(this ProcessStartInfo psi, IProcessEnvironment processEnvironment, SPath? workingDirectory = null) { processEnvironment.Configure(psi, workingDirectory); } @@ -533,7 +533,7 @@ public ProcessTaskWithListOutput( ProcessArguments = arguments; ProcessName = executable; } - + public virtual void Configure(ProcessStartInfo psi) { Guard.ArgumentNotNull(psi, "psi"); diff --git a/src/com.spoiledcat.processmanager/Editor/SpoiledCat.Unity.ProcessManager.csproj b/src/com.spoiledcat.processmanager/Editor/SpoiledCat.Unity.ProcessManager.csproj index 0b77160..3a9163e 100644 --- a/src/com.spoiledcat.processmanager/Editor/SpoiledCat.Unity.ProcessManager.csproj +++ b/src/com.spoiledcat.processmanager/Editor/SpoiledCat.Unity.ProcessManager.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/com.spoiledcat.processmanager/Editor/com.spoiledcat.processmanager.asmdef b/src/com.spoiledcat.processmanager/Editor/com.spoiledcat.processmanager.asmdef index a5d2764..cf2ea6d 100644 --- a/src/com.spoiledcat.processmanager/Editor/com.spoiledcat.processmanager.asmdef +++ b/src/com.spoiledcat.processmanager/Editor/com.spoiledcat.processmanager.asmdef @@ -3,7 +3,7 @@ "references": [ "com.spoiledcat.environment", "com.spoiledcat.logging", - "com.spoiledcat.niceio", + "com.spoiledcat.simpleio", "com.spoiledcat.threading", "com.spoiledcat.utilities" ], diff --git a/src/com.spoiledcat.processmanager/Tests/Editor/BaseTest_Shared.cs b/src/com.spoiledcat.processmanager/Tests/Editor/BaseTest_Shared.cs index 945ef85..6937331 100644 --- a/src/com.spoiledcat.processmanager/Tests/Editor/BaseTest_Shared.cs +++ b/src/com.spoiledcat.processmanager/Tests/Editor/BaseTest_Shared.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Threading.Tasks; using NUnit.Framework; -using SpoiledCat.NiceIO; +using SpoiledCat.SimpleIO; using SpoiledCat.Threading; using SpoiledCat.Extensions; using SpoiledCat.Logging; @@ -22,7 +22,7 @@ public partial class BaseTest : IDisposable private ITaskManager TaskManager { get; } protected void StopTest(Stopwatch watch, ILogging logger, ITaskManager taskManager, - NPath testPath, IEnvironment environment, IProcessManager processManager) + SPath testPath, IEnvironment environment, IProcessManager processManager) { watch.Stop(); logger.Trace($"END:{watch.ElapsedMilliseconds}ms"); diff --git a/src/com.spoiledcat.processmanager/Tests/Editor/UnityBaseTest.cs b/src/com.spoiledcat.processmanager/Tests/Editor/UnityBaseTest.cs index c3ef7cd..4508346 100644 --- a/src/com.spoiledcat.processmanager/Tests/Editor/UnityBaseTest.cs +++ b/src/com.spoiledcat.processmanager/Tests/Editor/UnityBaseTest.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.CompilerServices; using SpoiledCat.Logging; -using SpoiledCat.NiceIO; +using SpoiledCat.SimpleIO; using SpoiledCat.ProcessManager; using SpoiledCat.Threading; using SpoiledCat.Unity; @@ -45,7 +45,7 @@ public void Dispose() } protected void StartTest(out System.Diagnostics.Stopwatch watch, out ILogging logger, out ITaskManager taskManager, - out NPath testPath, out IEnvironment environment, out IProcessManager processManager, + out SPath testPath, out IEnvironment environment, out IProcessManager processManager, [CallerMemberName] string testName = "test") { logger = new LogFacade(testName, new UnityLogAdapter(), true); @@ -53,7 +53,7 @@ protected void StartTest(out System.Diagnostics.Stopwatch watch, out ILogging lo taskManager = TaskManager; - testPath = NPath.CreateTempDirectory(testName); + testPath = SPath.CreateTempDirectory(testName); environment = new UnityEnvironment(testName); ((UnityEnvironment)environment).SetWorkingDirectory(testPath); @@ -65,15 +65,15 @@ protected void StartTest(out System.Diagnostics.Stopwatch watch, out ILogging lo watch.Start(); } - protected NPath? testApp; + protected SPath? testApp; - protected NPath TestApp + protected SPath TestApp { get { if (!testApp.HasValue) { - testApp = "Packages/com.spoiledcat.processmanager/Tests/Helpers~/Helper.CommandLine.exe".ToNPath().Resolve(); + testApp = "Packages/com.spoiledcat.processmanager/Tests/Helpers~/Helper.CommandLine.exe".ToSPath().Resolve(); if (!testApp.Value.FileExists()) { UnityEngine.Debug.LogException(new InvalidOperationException("Test helper binaries are missing. Build the UnityTools.sln solution once with `dotnet build` in order to set up the tests.")); diff --git a/src/com.spoiledcat.processmanager/package.json b/src/com.spoiledcat.processmanager/package.json index 439a705..7ecaf40 100644 --- a/src/com.spoiledcat.processmanager/package.json +++ b/src/com.spoiledcat.processmanager/package.json @@ -19,7 +19,7 @@ "dependencies": { "com.spoiledcat.logging": "0.0.0-placeholder", "com.spoiledcat.environment": "0.0.0-placeholder", - "com.spoiledcat.niceio": "0.0.0-placeholder", + "com.spoiledcat.simpleio": "0.0.0-placeholder", "com.spoiledcat.threading": "0.0.0-placeholder", "com.spoiledcat.utilities": "0.0.0-placeholder" } diff --git a/src/com.spoiledcat.quick-console/Editor/QuickConsole.cs b/src/com.spoiledcat.quick-console/Editor/QuickConsole.cs index 187b49f..0788f32 100644 --- a/src/com.spoiledcat.quick-console/Editor/QuickConsole.cs +++ b/src/com.spoiledcat.quick-console/Editor/QuickConsole.cs @@ -18,7 +18,7 @@ namespace SpoiledCat { using Json; - using NiceIO; + using SimpleIO; using UI; using Extensions; @@ -360,7 +360,7 @@ public class Compiler "System.Linq", "System.IO", "SpoiledCat.Json", - "SpoiledCat.NiceIO", + "SpoiledCat.SimpleIO", }; private Dictionary @@ -451,7 +451,7 @@ public Compiler() { (string source, string className, string methodName) = GenerateSource(args, csharp); - compilerParameters.OutputAssembly = $"Temp/assembly_{className}.dll".ToNPath().ToString(); + compilerParameters.OutputAssembly = $"Temp/assembly_{className}.dll".ToSPath().ToString(); CompilerResults r = compiler.CompileAssemblyFromSource(compilerParameters, source); if (!r.Errors.HasErrors) diff --git a/src/com.spoiledcat.quick-console/Editor/SpoiledCat.Unity.QuickConsole.csproj b/src/com.spoiledcat.quick-console/Editor/SpoiledCat.Unity.QuickConsole.csproj index 4957910..60100ab 100644 --- a/src/com.spoiledcat.quick-console/Editor/SpoiledCat.Unity.QuickConsole.csproj +++ b/src/com.spoiledcat.quick-console/Editor/SpoiledCat.Unity.QuickConsole.csproj @@ -5,7 +5,7 @@ - + diff --git a/src/com.spoiledcat.quick-console/Editor/com.spoiledcat.quick-console.asmdef b/src/com.spoiledcat.quick-console/Editor/com.spoiledcat.quick-console.asmdef index f6d05f6..3e0d082 100644 --- a/src/com.spoiledcat.quick-console/Editor/com.spoiledcat.quick-console.asmdef +++ b/src/com.spoiledcat.quick-console/Editor/com.spoiledcat.quick-console.asmdef @@ -3,7 +3,7 @@ "references": [ "com.spoiledcat.simplejson", "com.spoiledcat.ui", - "com.spoiledcat.niceio" + "com.spoiledcat.simpleio" ], "optionalUnityReferences": [], "includePlatforms": [ diff --git a/src/com.spoiledcat.quick-console/package.json b/src/com.spoiledcat.quick-console/package.json index f2328ee..a45cc9d 100644 --- a/src/com.spoiledcat.quick-console/package.json +++ b/src/com.spoiledcat.quick-console/package.json @@ -17,7 +17,7 @@ "registry":"https://registry.spoiledcat.com/" }, "dependencies": { - "com.spoiledcat.niceio": "0.0.0-placeholder", + "com.spoiledcat.simpleio": "0.0.0-placeholder", "com.spoiledcat.ui": "0.0.0-placeholder" } } \ No newline at end of file diff --git a/src/com.spoiledcat.niceio/Documentation~/.gitignore b/src/com.spoiledcat.simpleio/Documentation~/.gitignore similarity index 100% rename from src/com.spoiledcat.niceio/Documentation~/.gitignore rename to src/com.spoiledcat.simpleio/Documentation~/.gitignore diff --git a/src/com.spoiledcat.simpleio/Editor.meta b/src/com.spoiledcat.simpleio/Editor.meta new file mode 100644 index 0000000..7a81234 --- /dev/null +++ b/src/com.spoiledcat.simpleio/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 25cb430dd56147c1951e96c5131c0f11 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/com.spoiledcat.niceio/Editor/NiceIO.cs b/src/com.spoiledcat.simpleio/Editor/SimpleIO.cs similarity index 85% rename from src/com.spoiledcat.niceio/Editor/NiceIO.cs rename to src/com.spoiledcat.simpleio/Editor/SimpleIO.cs index 357af1f..e452a5b 100644 --- a/src/com.spoiledcat.niceio/Editor/NiceIO.cs +++ b/src/com.spoiledcat.simpleio/Editor/SimpleIO.cs @@ -1,5 +1,5 @@ //----------------------------------------------------------------------- -// +// // // The MIT License(MIT) // ===================== @@ -42,21 +42,21 @@ using System.Reflection; using System.Text; -namespace SpoiledCat.NiceIO +namespace SpoiledCat.SimpleIO { [Serializable] [DebuggerDisplay("{DebuggerDisplay,nq}")] - public struct NPath : IEquatable, IComparable + public struct SPath : IEquatable, IComparable { - public static NPath Default; + public static SPath Default; private readonly string[] _elements; private readonly string _driveLetter; #region construction - public NPath(string path) + public SPath(string path) { if (path == null) throw new ArgumentNullException("path"); @@ -80,14 +80,14 @@ public NPath(string path) } } - public static (NPath, bool) TryParse(string path) + public static (SPath, bool) TryParse(string path) { - if (path == null) return (NPath.Default, false); - var p = new NPath(path); + if (path == null) return (SPath.Default, false); + var p = new SPath(path); return (p, !p.IsEmpty || p.IsRoot); } - private NPath(string[] elements, bool isRelative, string driveLetter) + private SPath(string[] elements, bool isRelative, string driveLetter) { _elements = elements; IsRelative = isRelative; @@ -146,24 +146,24 @@ private static bool IsRelativeFromSplitString(string[] split) return split[0].Length != 0 || !split.Any(s => s.Length > 0); } - public NPath Combine(params string[] append) + public SPath Combine(params string[] append) { - return Combine(append.Select(a => new NPath(a)).ToArray()); + return Combine(append.Select(a => new SPath(a)).ToArray()); } - public NPath Combine(params NPath[] append) + public SPath Combine(params SPath[] append) { ThrowIfNotInitialized(); if (!append.All(p => p.IsRelative)) throw new ArgumentException("You cannot .Combine a non-relative path"); - return new NPath( + return new SPath( ParseSplitStringIntoElements(_elements.Concat(append.SelectMany(p => p._elements)), IsRelative), IsRelative, _driveLetter); } - public NPath Parent { + public SPath Parent { get { ThrowIfNotInitialized(); @@ -172,11 +172,11 @@ public NPath Parent { var newElements = _elements.Take(_elements.Length - 1).ToArray(); - return new NPath(newElements, IsRelative, _driveLetter); + return new SPath(newElements, IsRelative, _driveLetter); } } - public NPath RelativeTo(NPath path) + public SPath RelativeTo(SPath path) { ThrowIfNotInitialized(); @@ -187,7 +187,7 @@ public NPath RelativeTo(NPath path) "Path.RelativeTo() was invoked with two paths that are on different volumes. invoked on: " + ToString() + " asked to be made relative to: " + path); - NPath commonParent = Default; + SPath commonParent = Default; foreach (var parent in RecursiveParents) { commonParent = path.RecursiveParents.FirstOrDefault(otherParent => otherParent == parent); @@ -206,15 +206,15 @@ public NPath RelativeTo(NPath path) ToString() + " asked to be made relative to: " + path); var depthDiff = path.Depth - commonParent.Depth; - return new NPath( + return new SPath( Enumerable.Repeat("..", depthDiff).Concat(_elements.Skip(commonParent.Depth)).ToArray(), true, null); } - return new NPath(_elements.Skip(path._elements.Length).ToArray(), true, null); + return new SPath(_elements.Skip(path._elements.Length).ToArray(), true, null); } - public NPath GetCommonParent(NPath path) + public SPath GetCommonParent(SPath path) { ThrowIfNotInitialized(); @@ -223,8 +223,8 @@ public NPath GetCommonParent(NPath path) if (!IsRelative && !path.IsRelative && _driveLetter != path._driveLetter) return Default; - NPath commonParent = Default; - foreach (var parent in new List { this }.Concat(RecursiveParents)) + SPath commonParent = Default; + foreach (var parent in new List { this }.Concat(RecursiveParents)) { commonParent = path.RecursiveParents.FirstOrDefault(otherParent => otherParent == parent); if (commonParent.IsInitialized) @@ -238,7 +238,7 @@ public NPath GetCommonParent(NPath path) return path; } - public NPath ChangeExtension(string extension) + public SPath ChangeExtension(string extension) { ThrowIfNotInitialized(); ThrowIfRoot(); @@ -248,7 +248,7 @@ public NPath ChangeExtension(string extension) FileSystem.ChangeExtension(_elements[_elements.Length - 1], WithDot(extension)); if (extension == string.Empty) newElements[newElements.Length - 1] = newElements[newElements.Length - 1].TrimEnd('.'); - return new NPath(newElements, IsRelative, _driveLetter); + return new SPath(newElements, IsRelative, _driveLetter); } #endregion construction @@ -303,10 +303,10 @@ public bool Exists(string append) { return Exists(); } - return Exists(new NPath(append)); + return Exists(new SPath(append)); } - public bool Exists(NPath append) + public bool Exists(SPath append) { ThrowIfNotInitialized(); if (!append.IsInitialized) @@ -325,10 +325,10 @@ public bool DirectoryExists(string append) ThrowIfNotInitialized(); if (String.IsNullOrEmpty(append)) return DirectoryExists(); - return DirectoryExists(new NPath(append)); + return DirectoryExists(new SPath(append)); } - public bool DirectoryExists(NPath append) + public bool DirectoryExists(SPath append) { ThrowIfNotInitialized(); if (!append.IsInitialized) @@ -347,10 +347,10 @@ public bool FileExists(string append) ThrowIfNotInitialized(); if (String.IsNullOrEmpty(append)) return FileExists(); - return FileExists(new NPath(append)); + return FileExists(new SPath(append)); } - public bool FileExists(NPath append) + public bool FileExists(SPath append) { ThrowIfNotInitialized(); if (!append.IsInitialized) @@ -418,7 +418,7 @@ public string ToString(SlashMode slashMode) return sb.ToString(); } - public static implicit operator string(NPath path) + public static implicit operator string(SPath path) { return path.ToString(); } @@ -438,19 +438,19 @@ static char Slash(SlashMode slashMode) public override bool Equals(Object other) { - if (other is NPath) + if (other is SPath) { - return Equals((NPath)other); + return Equals((SPath)other); } return false; } - public bool Equals(NPath p) + public bool Equals(SPath p) { if (p.IsInitialized != IsInitialized) return false; - // return early if we're comparing two NPath.Default instances + // return early if we're comparing two SPath.Default instances if (!IsInitialized) return true; @@ -470,7 +470,7 @@ public bool Equals(NPath p) return true; } - public static bool operator ==(NPath lhs, NPath rhs) + public static bool operator ==(SPath lhs, SPath rhs) { return lhs.Equals(rhs); } @@ -495,13 +495,13 @@ public override int GetHashCode() public int CompareTo(object other) { - if (!(other is NPath)) + if (!(other is SPath)) return -1; - return ToString().CompareTo(((NPath)other).ToString()); + return ToString().CompareTo(((SPath)other).ToString()); } - public static bool operator !=(NPath lhs, NPath rhs) + public static bool operator !=(SPath lhs, SPath rhs) { return !(lhs.Equals(rhs)); } @@ -535,35 +535,35 @@ public bool IsRoot { #region directory enumeration - public IEnumerable Files(string filter, bool recurse = false) + public IEnumerable Files(string filter, bool recurse = false) { return FileSystem .GetFiles(MakeAbsolute(), filter, - recurse ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly).Select(s => new NPath(s)); + recurse ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly).Select(s => new SPath(s)); } - public IEnumerable Files(bool recurse = false) + public IEnumerable Files(bool recurse = false) { return Files("*", recurse); } - public IEnumerable Contents(string filter, bool recurse = false) + public IEnumerable Contents(string filter, bool recurse = false) { return Files(filter, recurse).Concat(Directories(filter, recurse)); } - public IEnumerable Contents(bool recurse = false) + public IEnumerable Contents(bool recurse = false) { return Contents("*", recurse); } - public IEnumerable Directories(string filter, bool recurse = false) + public IEnumerable Directories(string filter, bool recurse = false) { return FileSystem.GetDirectories(MakeAbsolute(), filter, - recurse ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly).Select(s => new NPath(s)); + recurse ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly).Select(s => new SPath(s)); } - public IEnumerable Directories(bool recurse = false) + public IEnumerable Directories(bool recurse = false) { return Directories("*", recurse); } @@ -572,7 +572,7 @@ public IEnumerable Directories(bool recurse = false) #region filesystem writing operations - public NPath CreateFile() + public SPath CreateFile() { ThrowIfNotInitialized(); ThrowIfRelative(); @@ -582,12 +582,12 @@ public NPath CreateFile() return this; } - public NPath CreateFile(string file) + public SPath CreateFile(string file) { - return CreateFile(new NPath(file)); + return CreateFile(new SPath(file)); } - public NPath CreateFile(NPath file) + public SPath CreateFile(SPath file) { ThrowIfNotInitialized(); if (!file.IsRelative) @@ -596,7 +596,7 @@ public NPath CreateFile(NPath file) return Combine(file).CreateFile(); } - public NPath CreateDirectory() + public SPath CreateDirectory() { ThrowIfNotInitialized(); ThrowIfRelative(); @@ -610,12 +610,12 @@ public NPath CreateDirectory() return this; } - public NPath CreateDirectory(string directory) + public SPath CreateDirectory(string directory) { - return CreateDirectory(new NPath(directory)); + return CreateDirectory(new SPath(directory)); } - public NPath CreateDirectory(NPath directory) + public SPath CreateDirectory(SPath directory) { ThrowIfNotInitialized(); if (!directory.IsRelative) @@ -624,22 +624,22 @@ public NPath CreateDirectory(NPath directory) return Combine(directory).CreateDirectory(); } - public NPath Copy(string dest) + public SPath Copy(string dest) { - return Copy(new NPath(dest)); + return Copy(new SPath(dest)); } - public NPath Copy(string dest, Func fileFilter) + public SPath Copy(string dest, Func fileFilter) { - return Copy(new NPath(dest), fileFilter); + return Copy(new SPath(dest), fileFilter); } - public NPath Copy(NPath dest) + public SPath Copy(SPath dest) { return Copy(dest, p => true); } - public NPath Copy(NPath dest, Func fileFilter) + public SPath Copy(SPath dest, Func fileFilter) { ThrowIfNotInitialized(); ThrowIfNotInitialized(dest); @@ -653,17 +653,17 @@ public NPath Copy(NPath dest, Func fileFilter) return CopyWithDeterminedDestination(dest, fileFilter); } - public NPath MakeAbsolute() + public SPath MakeAbsolute() { ThrowIfNotInitialized(); if (!IsRelative) return this; - return NPath.CurrentDirectory.Combine(this); + return SPath.CurrentDirectory.Combine(this); } - NPath CopyWithDeterminedDestination(NPath absoluteDestination, Func fileFilter) + SPath CopyWithDeterminedDestination(SPath absoluteDestination, Func fileFilter) { if (absoluteDestination.IsRelative) throw new ArgumentException("absoluteDestination must be absolute"); @@ -732,7 +732,7 @@ public void DeleteIfExists(DeleteMode deleteMode = DeleteMode.Normal) Delete(deleteMode); } - public NPath DeleteContents() + public SPath DeleteContents() { ThrowIfNotInitialized(); ThrowIfRelative(); @@ -764,35 +764,35 @@ public NPath DeleteContents() return EnsureDirectoryExists(); } - public static NPath CreateTempDirectory(string myprefix) + public static SPath CreateTempDirectory(string myprefix) { var random = new Random(); while (true) { - var candidate = new NPath(FileSystem.TempPath+ "/" + myprefix + "_" + random.Next()); + var candidate = new SPath(FileSystem.TempPath+ "/" + myprefix + "_" + random.Next()); if (!candidate.Exists()) return candidate.CreateDirectory(); } } - public static NPath GetTempFilename(string myprefix = "") + public static SPath GetTempFilename(string myprefix = "") { var random = new Random(); var prefix = FileSystem.TempPath+ "/" + (String.IsNullOrEmpty(myprefix) ? "" : myprefix + "_"); while (true) { - var candidate = new NPath(prefix + random.Next()); + var candidate = new SPath(prefix + random.Next()); if (!candidate.Exists()) return candidate; } } - public NPath Move(string dest) + public SPath Move(string dest) { - return Move(new NPath(dest)); + return Move(new SPath(dest)); } - public NPath Move(NPath dest) + public SPath Move(SPath dest) { ThrowIfNotInitialized(); ThrowIfNotInitialized(dest); @@ -828,7 +828,7 @@ public NPath Move(NPath dest) "Move() called on a path that doesn't exist: " + MakeAbsolute().ToString()); } - public NPath WriteAllText(string contents) + public SPath WriteAllText(string contents) { ThrowIfNotInitialized(); EnsureParentDirectoryExists(); @@ -842,7 +842,7 @@ public string ReadAllText() return FileSystem.ReadAllText(MakeAbsolute()); } - public NPath WriteAllText(string contents, Encoding encoding) + public SPath WriteAllText(string contents, Encoding encoding) { ThrowIfNotInitialized(); EnsureParentDirectoryExists(); @@ -856,7 +856,7 @@ public string ReadAllText(Encoding encoding) return FileSystem.ReadAllText(MakeAbsolute(), encoding); } - public NPath WriteLines(string[] contents) + public SPath WriteLines(string[] contents) { ThrowIfNotInitialized(); EnsureParentDirectoryExists(); @@ -864,7 +864,7 @@ public NPath WriteLines(string[] contents) return this; } - public NPath WriteAllLines(string[] contents) + public SPath WriteAllLines(string[] contents) { ThrowIfNotInitialized(); EnsureParentDirectoryExists(); @@ -878,7 +878,7 @@ public string[] ReadAllLines() return FileSystem.ReadAllLines(MakeAbsolute()); } - public NPath WriteAllBytes(byte[] contents) + public SPath WriteAllBytes(byte[] contents) { ThrowIfNotInitialized(); EnsureParentDirectoryExists(); @@ -905,7 +905,7 @@ public Stream OpenWrite(FileMode mode) } - public IEnumerable CopyFiles(NPath destination, bool recurse, Func fileFilter = null) + public IEnumerable CopyFiles(SPath destination, bool recurse, Func fileFilter = null) { ThrowIfNotInitialized(); ThrowIfNotInitialized(destination); @@ -916,7 +916,7 @@ public IEnumerable CopyFiles(NPath destination, bool recurse, Func file.Copy(destination.Combine(file.RelativeTo(_this)))).ToArray(); } - public IEnumerable MoveFiles(NPath destination, bool recurse, Func fileFilter = null) + public IEnumerable MoveFiles(SPath destination, bool recurse, Func fileFilter = null) { ThrowIfNotInitialized(); ThrowIfNotInitialized(destination); @@ -935,47 +935,47 @@ public IEnumerable MoveFiles(NPath destination, bool recurse, Func RecursiveParents { + public IEnumerable RecursiveParents { get { ThrowIfNotInitialized(); var candidate = this; @@ -1109,12 +1109,12 @@ public IEnumerable RecursiveParents { } } - public NPath ParentContaining(string needle) + public SPath ParentContaining(string needle) { - return ParentContaining(new NPath(needle)); + return ParentContaining(new SPath(needle)); } - public NPath ParentContaining(NPath needle) + public SPath ParentContaining(SPath needle) { ThrowIfNotInitialized(); ThrowIfNotInitialized(needle); @@ -1123,7 +1123,7 @@ public NPath ParentContaining(NPath needle) return RecursiveParents.FirstOrDefault(p => p.Exists(needle)); } - static bool AlwaysTrue(NPath p) + static bool AlwaysTrue(SPath p) { return true; } @@ -1172,12 +1172,12 @@ private static StringComparison PathStringComparison { #endif static class Extensions { - public static IEnumerable Copy(this IEnumerable self, string dest) + public static IEnumerable Copy(this IEnumerable self, string dest) { - return Copy(self, new NPath(dest)); + return Copy(self, new SPath(dest)); } - public static IEnumerable Copy(this IEnumerable self, NPath dest) + public static IEnumerable Copy(this IEnumerable self, SPath dest) { if (dest.IsRelative) throw new ArgumentException("When copying multiple files, the destination cannot be a relative path"); @@ -1185,12 +1185,12 @@ public static IEnumerable Copy(this IEnumerable self, NPath dest) return self.Select(p => p.Copy(dest.Combine(p.FileName))).ToArray(); } - public static IEnumerable Move(this IEnumerable self, string dest) + public static IEnumerable Move(this IEnumerable self, string dest) { - return Move(self, new NPath(dest)); + return Move(self, new SPath(dest)); } - public static IEnumerable Move(this IEnumerable self, NPath dest) + public static IEnumerable Move(this IEnumerable self, SPath dest) { if (dest.IsRelative) throw new ArgumentException("When moving multiple files, the destination cannot be a relative path"); @@ -1198,38 +1198,38 @@ public static IEnumerable Move(this IEnumerable self, NPath dest) return self.Select(p => p.Move(dest.Combine(p.FileName))).ToArray(); } - public static IEnumerable Delete(this IEnumerable self) + public static IEnumerable Delete(this IEnumerable self) { foreach (var p in self) p.Delete(); return self; } - public static IEnumerable InQuotes(this IEnumerable self, SlashMode forward = SlashMode.Native) + public static IEnumerable InQuotes(this IEnumerable self, SlashMode forward = SlashMode.Native) { return self.Select(p => p.InQuotes(forward)); } - public static NPath ToNPath(this string path) + public static SPath ToSPath(this string path) { if (path == null) - return NPath.Default; - return new NPath(path); + return SPath.Default; + return new SPath(path); } - public static NPath Resolve(this NPath path) + public static SPath Resolve(this SPath path) { if (!path.IsInitialized || !path.Exists()) return path; // because Unity sometimes lies about where things are - string fullPath = NPath.FileSystem.GetFullPath(path.ToString()); - if (!NPath.IsUnix) - return fullPath.ToNPath(); - return NPath.FileSystem.Resolve(fullPath).ToNPath(); + string fullPath = SPath.FileSystem.GetFullPath(path.ToString()); + if (!SPath.IsUnix) + return fullPath.ToSPath(); + return SPath.FileSystem.Resolve(fullPath).ToSPath(); } - public static NPath CreateTempDirectory(this NPath baseDir, string myprefix = "") + public static SPath CreateTempDirectory(this SPath baseDir, string myprefix = "") { var random = new Random(); while (true) @@ -1358,21 +1358,21 @@ public string GetFolderPath(Environment.SpecialFolder folder) case Environment.SpecialFolder.LocalApplicationData: if (localAppData == null) { - if (NPath.IsMac) - localAppData = NPath.HomeDirectory.Combine("Library", "Application Support"); + if (SPath.IsMac) + localAppData = SPath.HomeDirectory.Combine("Library", "Application Support"); else - localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData).ToNPath(); + localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData).ToSPath(); } return localAppData; case Environment.SpecialFolder.CommonApplicationData: if (commonAppData == null) { - if (NPath.IsWindows) - commonAppData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData).ToNPath(); + if (SPath.IsWindows) + commonAppData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData).ToSPath(); else { // there is no such thing on the mac that is guaranteed to be user accessible (/usr/local might not be) - commonAppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToNPath(); + commonAppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToSPath(); } } return commonAppData; @@ -1473,7 +1473,7 @@ public IEnumerable GetFiles(string path, string pattern, SearchOption se yield break; - if (NPath.IsUnix) + if (SPath.IsUnix) { try { @@ -1487,7 +1487,7 @@ public IEnumerable GetFiles(string path, string pattern, SearchOption se { var realdir = dir; - if (NPath.IsUnix) + if (SPath.IsUnix) { try { @@ -1691,10 +1691,10 @@ public string HomeDirectory { if (homeDirectory == null) { - if (NPath.IsUnix) - homeDirectory = new NPath(Environment.GetEnvironmentVariable("HOME")); + if (SPath.IsUnix) + homeDirectory = new SPath(Environment.GetEnvironmentVariable("HOME")); else - homeDirectory = new NPath(Environment.GetEnvironmentVariable("USERPROFILE")); + homeDirectory = new SPath(Environment.GetEnvironmentVariable("USERPROFILE")); } return homeDirectory; } diff --git a/src/com.spoiledcat.niceio/Editor/NiceIO.cs.meta b/src/com.spoiledcat.simpleio/Editor/SimpleIO.cs.meta similarity index 60% rename from src/com.spoiledcat.niceio/Editor/NiceIO.cs.meta rename to src/com.spoiledcat.simpleio/Editor/SimpleIO.cs.meta index 99570ba..c2eab79 100644 --- a/src/com.spoiledcat.niceio/Editor/NiceIO.cs.meta +++ b/src/com.spoiledcat.simpleio/Editor/SimpleIO.cs.meta @@ -1,11 +1,11 @@ fileFormatVersion: 2 -guid: 8271bf3f02c355f4591cd204312b2dcb +guid: cb075df261eb4f07966ff24e2acb7ac7 MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/com.spoiledcat.niceio/Editor/SpoiledCat.Unity.NiceIO.csproj b/src/com.spoiledcat.simpleio/Editor/SpoiledCat.Unity.SimpleIO.csproj similarity index 100% rename from src/com.spoiledcat.niceio/Editor/SpoiledCat.Unity.NiceIO.csproj rename to src/com.spoiledcat.simpleio/Editor/SpoiledCat.Unity.SimpleIO.csproj diff --git a/src/com.spoiledcat.simpleio/Editor/SpoiledCat.Unity.SimpleIO.csproj.meta b/src/com.spoiledcat.simpleio/Editor/SpoiledCat.Unity.SimpleIO.csproj.meta new file mode 100644 index 0000000..05ec4c8 --- /dev/null +++ b/src/com.spoiledcat.simpleio/Editor/SpoiledCat.Unity.SimpleIO.csproj.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 2f51ccf4fa5f45489eaeedbf7945ee27 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/com.spoiledcat.niceio/Editor/com.spoiledcat.niceio.asmdef b/src/com.spoiledcat.simpleio/Editor/com.spoiledcat.simpleio.asmdef similarity index 89% rename from src/com.spoiledcat.niceio/Editor/com.spoiledcat.niceio.asmdef rename to src/com.spoiledcat.simpleio/Editor/com.spoiledcat.simpleio.asmdef index 6e1c7a2..2af13fb 100644 --- a/src/com.spoiledcat.niceio/Editor/com.spoiledcat.niceio.asmdef +++ b/src/com.spoiledcat.simpleio/Editor/com.spoiledcat.simpleio.asmdef @@ -1,5 +1,5 @@ { - "name": "com.spoiledcat.niceio", + "name": "com.spoiledcat.simpleio", "references": [], "optionalUnityReferences": [], "includePlatforms": [ diff --git a/src/com.spoiledcat.simpleio/Editor/com.spoiledcat.simpleio.asmdef.meta b/src/com.spoiledcat.simpleio/Editor/com.spoiledcat.simpleio.asmdef.meta new file mode 100644 index 0000000..a8c99e2 --- /dev/null +++ b/src/com.spoiledcat.simpleio/Editor/com.spoiledcat.simpleio.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 0419205829404da2bdd224c9364dcbb9 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/com.spoiledcat.niceio/LICENSE b/src/com.spoiledcat.simpleio/LICENSE similarity index 100% rename from src/com.spoiledcat.niceio/LICENSE rename to src/com.spoiledcat.simpleio/LICENSE diff --git a/src/com.spoiledcat.simpleio/LICENSE.meta b/src/com.spoiledcat.simpleio/LICENSE.meta new file mode 100644 index 0000000..da7b84f --- /dev/null +++ b/src/com.spoiledcat.simpleio/LICENSE.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9b8defd2dbe248f1bcbcba245682ebf3 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/com.spoiledcat.niceio/package.json b/src/com.spoiledcat.simpleio/package.json similarity index 74% rename from src/com.spoiledcat.niceio/package.json rename to src/com.spoiledcat.simpleio/package.json index d334f5f..4c61f58 100644 --- a/src/com.spoiledcat.niceio/package.json +++ b/src/com.spoiledcat.simpleio/package.json @@ -1,7 +1,7 @@ { - "name": "com.spoiledcat.niceio", - "displayName": "SpoiledCat NiceIO", - "description": "A nice IO abstraction", + "name": "com.spoiledcat.simple", + "displayName": "SpoiledCat SimpleIO", + "description": "A simple IO abstraction", "version": "0.0.0-placeholder", "license" : "MIT", "author": { diff --git a/src/com.spoiledcat.simpleio/package.json.meta b/src/com.spoiledcat.simpleio/package.json.meta new file mode 100644 index 0000000..0735270 --- /dev/null +++ b/src/com.spoiledcat.simpleio/package.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 44997dde56834aa5a5337b048baa574b +PackageManifestImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/com.spoiledcat.threading.tasks/Editor/DownloadTask.cs b/src/com.spoiledcat.threading.tasks/Editor/DownloadTask.cs index bdb01f9..c8e6df8 100644 --- a/src/com.spoiledcat.threading.tasks/Editor/DownloadTask.cs +++ b/src/com.spoiledcat.threading.tasks/Editor/DownloadTask.cs @@ -12,11 +12,11 @@ namespace SpoiledCat.Threading { using Logging; - using NiceIO; + using SimpleIO; using Utilities; - public class DownloadTask : TaskBase + public class DownloadTask : TaskBase { - public DownloadTask(ITaskManager taskManager, UriString url, NPath targetDirectory, string filename = null, int retryCount = 0) + public DownloadTask(ITaskManager taskManager, UriString url, SPath targetDirectory, string filename = null, int retryCount = 0) : this(taskManager, taskManager?.Token ?? default, url, targetDirectory, filename, retryCount) {} @@ -24,7 +24,7 @@ public DownloadTask( ITaskManager taskManager, CancellationToken token, UriString url, - NPath targetDirectory, + SPath targetDirectory, string filename = null, int retryCount = 0) : base(taskManager, token) @@ -47,7 +47,7 @@ protected string BaseRunWithReturn(bool success) return base.RunWithReturn(success); } - protected override NPath RunWithReturn(bool success) + protected override SPath RunWithReturn(bool success) { var result = base.RunWithReturn(success); try @@ -69,7 +69,7 @@ protected override NPath RunWithReturn(bool success) /// /// /// - protected virtual NPath RunDownload(bool success) + protected virtual SPath RunDownload(bool success) { Exception exception = null; var attempts = 0; @@ -119,11 +119,11 @@ protected virtual NPath RunDownload(bool success) public UriString Url { get; } - public NPath TargetDirectory { get; } + public SPath TargetDirectory { get; } public string Filename { get; } - public NPath Destination => TargetDirectory.Combine(Filename); + public SPath Destination => TargetDirectory.Combine(Filename); protected int RetryCount { get; } } @@ -159,19 +159,19 @@ public static WebResponse GetResponseWithoutException(this WebRequest request) public class DownloadData { - public DownloadData(UriString url, NPath file) + public DownloadData(UriString url, SPath file) { Url = url; File = file; } public UriString Url { get; } - public NPath File { get; } + public SPath File { get; } } - public class Downloader : TaskQueue + public class Downloader : TaskQueue { - public event Action OnDownloadComplete; + public event Action OnDownloadComplete; public event Action OnDownloadFailed; public event Action OnDownloadStart; @@ -270,7 +270,7 @@ public static bool Download(ILogging logger, } } - public void QueueDownload(UriString url, NPath targetDirectory, string filename = null, int retryCount = 0) + public void QueueDownload(UriString url, SPath targetDirectory, string filename = null, int retryCount = 0) { var download = new DownloadTask(TaskManager, url, targetDirectory, filename, retryCount); download.OnStart += t => OnDownloadStart?.Invoke(((DownloadTask)t).Url); diff --git a/src/com.spoiledcat.threading.tasks/Editor/UnzipTask.cs b/src/com.spoiledcat.threading.tasks/Editor/UnzipTask.cs index ad86a52..4346abc 100644 --- a/src/com.spoiledcat.threading.tasks/Editor/UnzipTask.cs +++ b/src/com.spoiledcat.threading.tasks/Editor/UnzipTask.cs @@ -9,23 +9,23 @@ namespace SpoiledCat.Threading { - using NiceIO; + using SimpleIO; using Utilities; - public class UnzipTask : TaskBase + public class UnzipTask : TaskBase { private readonly string archiveFilePath; - private readonly NPath extractedPath; + private readonly SPath extractedPath; private readonly IFileSystem fileSystem; private readonly IZipHelper zipHelper; private ProgressReporter progressReporter = new ProgressReporter(); private Dictionary tasks = new Dictionary(); - public UnzipTask(ITaskManager taskManager, NPath archiveFilePath, NPath extractedPath) - : this(taskManager, taskManager?.Token ?? default, archiveFilePath, extractedPath, null, NPath.FileSystem) + public UnzipTask(ITaskManager taskManager, SPath archiveFilePath, SPath extractedPath) + : this(taskManager, taskManager?.Token ?? default, archiveFilePath, extractedPath, null, SPath.FileSystem) {} - public UnzipTask(ITaskManager taskManager, CancellationToken token, NPath archiveFilePath, NPath extractedPath, + public UnzipTask(ITaskManager taskManager, CancellationToken token, SPath archiveFilePath, SPath extractedPath, IZipHelper zipHelper, IFileSystem fileSystem) : base(taskManager, token) { @@ -38,12 +38,12 @@ public UnzipTask(ITaskManager taskManager, CancellationToken token, NPath archiv progressReporter.OnProgress += progress.UpdateProgress; } - protected NPath BaseRun(bool success) + protected SPath BaseRun(bool success) { return base.RunWithReturn(success); } - protected override NPath RunWithReturn(bool success) + protected override SPath RunWithReturn(bool success) { var ret = BaseRun(success); try @@ -58,7 +58,7 @@ protected override NPath RunWithReturn(bool success) return ret; } - protected virtual NPath RunUnzip(bool success) + protected virtual SPath RunUnzip(bool success) { Logger.Trace("Unzip File: {0} to Path: {1}", archiveFilePath, extractedPath); diff --git a/src/com.spoiledcat.threading.tasks/Editor/com.spoiledcat.threading.tasks.asmdef b/src/com.spoiledcat.threading.tasks/Editor/com.spoiledcat.threading.tasks.asmdef index 207db40..1ecc015 100644 --- a/src/com.spoiledcat.threading.tasks/Editor/com.spoiledcat.threading.tasks.asmdef +++ b/src/com.spoiledcat.threading.tasks/Editor/com.spoiledcat.threading.tasks.asmdef @@ -2,7 +2,7 @@ "name": "com.spoiledcat.threading.tasks", "references": [ "com.spoiledcat.logging", - "com.spoiledcat.niceio", + "com.spoiledcat.simpleio", "com.spoiledcat.utilities", "com.spoiledcat.threading" ], diff --git a/src/com.spoiledcat.threading/Editor/Base/ActionTask.cs b/src/com.spoiledcat.threading/Editor/Base/ActionTask.cs index bdd79f4..1502769 100644 --- a/src/com.spoiledcat.threading/Editor/Base/ActionTask.cs +++ b/src/com.spoiledcat.threading/Editor/Base/ActionTask.cs @@ -118,7 +118,7 @@ protected TaskQueue() {} /// /// If is not assignable to , you must pass a - /// method to convert between the two. Implicit conversions don't count (so even though NPath has an implicit + /// method to convert between the two. Implicit conversions don't count (so even though SPath has an implicit /// conversion to string, you still need to pass in a converter) /// /// @@ -129,7 +129,7 @@ public TaskQueue(ITaskManager taskManager, Func, TResult> res /// /// If is not assignable to , you must pass a - /// method to convert between the two. Implicit conversions don't count (so even though NPath has an implicit + /// method to convert between the two. Implicit conversions don't count (so even though SPath has an implicit /// conversion to string, you still need to pass in a converter) /// /// diff --git a/src/com.spoiledcat.threading/Editor/com.spoiledcat.threading.asmdef b/src/com.spoiledcat.threading/Editor/com.spoiledcat.threading.asmdef index b95a558..ffbcbe2 100644 --- a/src/com.spoiledcat.threading/Editor/com.spoiledcat.threading.asmdef +++ b/src/com.spoiledcat.threading/Editor/com.spoiledcat.threading.asmdef @@ -2,7 +2,7 @@ "name": "com.spoiledcat.threading", "references": [ "com.spoiledcat.logging", - "com.spoiledcat.niceio", + "com.spoiledcat.simpleio", "com.spoiledcat.utilities" ], "optionalUnityReferences": [], diff --git a/src/com.spoiledcat.threading/Tests/Editor/TaskQueueTests.cs b/src/com.spoiledcat.threading/Tests/Editor/TaskQueueTests.cs index 45fbf68..57cd4db 100644 --- a/src/com.spoiledcat.threading/Tests/Editor/TaskQueueTests.cs +++ b/src/com.spoiledcat.threading/Tests/Editor/TaskQueueTests.cs @@ -6,7 +6,7 @@ using NUnit.Framework; using BaseTests; using SpoiledCat.Extensions; -using SpoiledCat.NiceIO; +using SpoiledCat.SimpleIO; using SpoiledCat.Threading; namespace ThreadingTests @@ -99,9 +99,9 @@ public void ThrowsIfCannotConvert() StartTest(out var watch, out var logger, out var taskManager); Assert.Throws(() => new TaskQueue(taskManager)); - // NPath has an implicit operator to string, but we cannot verify this without using + // SPath has an implicit operator to string, but we cannot verify this without using // reflection, so a converter is required - Assert.Throws(() => new TaskQueue(taskManager)); + Assert.Throws(() => new TaskQueue(taskManager)); StopTest(watch, logger, taskManager); } diff --git a/src/com.spoiledcat.utilities/Editor/SpoiledCat.Unity.Utilities.csproj b/src/com.spoiledcat.utilities/Editor/SpoiledCat.Unity.Utilities.csproj index 5514563..89467c2 100644 --- a/src/com.spoiledcat.utilities/Editor/SpoiledCat.Unity.Utilities.csproj +++ b/src/com.spoiledcat.utilities/Editor/SpoiledCat.Unity.Utilities.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/com.spoiledcat.utilities/Editor/Utilities/AssemblyResources.cs b/src/com.spoiledcat.utilities/Editor/Utilities/AssemblyResources.cs index 0ee8afb..f5d8c6d 100644 --- a/src/com.spoiledcat.utilities/Editor/Utilities/AssemblyResources.cs +++ b/src/com.spoiledcat.utilities/Editor/Utilities/AssemblyResources.cs @@ -9,7 +9,7 @@ namespace SpoiledCat.Utilities { - using NiceIO; + using SimpleIO; using Extensions; using Unity; @@ -22,7 +22,7 @@ public enum ResourceType public class AssemblyResources { - public static NPath ToFile(ResourceType resourceType, string resource, NPath destinationPath, IEnvironment environment) + public static SPath ToFile(ResourceType resourceType, string resource, SPath destinationPath, IEnvironment environment) { var target = destinationPath.Combine(resource); var source = TryGetFile(resourceType, resource, environment); @@ -31,7 +31,7 @@ public static NPath ToFile(ResourceType resourceType, string resource, NPath des target.DeleteIfExists(); return source.Copy(target); } - return NPath.Default; + return SPath.Default; } public static Stream ToStream(ResourceType resourceType, string resource, IEnvironment environment) @@ -90,7 +90,7 @@ Each file's name is their physical path in the project. if (stream != null) return stream; - NPath possiblePath = environment.ExtensionInstallPath.Combine(type, os, resource); + SPath possiblePath = environment.ExtensionInstallPath.Combine(type, os, resource); if (possiblePath.FileExists()) { return new MemoryStream(possiblePath.ReadAllBytes()); @@ -98,7 +98,7 @@ Each file's name is their physical path in the project. return null; } - private static NPath TryGetFile(ResourceType resourceType, string resource, IEnvironment environment) + private static SPath TryGetFile(ResourceType resourceType, string resource, IEnvironment environment) { /* This function attempts to get files embedded in the callers assembly. @@ -114,17 +114,17 @@ Each file's name is their physical path in the project. var stream = TryGetResource(resourceType, type, os, resource); if (stream != null) { - var target = NPath.GetTempFilename(); + var target = SPath.GetTempFilename(); return target.WriteAllBytes(stream.ToByteArray()); } - NPath possiblePath = environment.ExtensionInstallPath.Combine(type, os, resource); + SPath possiblePath = environment.ExtensionInstallPath.Combine(type, os, resource); if (possiblePath.FileExists()) { return possiblePath; } - return NPath.Default; + return SPath.Default; } } } diff --git a/src/com.spoiledcat.utilities/Editor/Utilities/CopyHelper.cs b/src/com.spoiledcat.utilities/Editor/Utilities/CopyHelper.cs index 4244157..0d3f5e7 100644 --- a/src/com.spoiledcat.utilities/Editor/Utilities/CopyHelper.cs +++ b/src/com.spoiledcat.utilities/Editor/Utilities/CopyHelper.cs @@ -8,13 +8,13 @@ namespace SpoiledCat.Utilities { using Logging; - using NiceIO; + using SimpleIO; public static class CopyHelper { private static readonly ILogging Logger = LogHelper.GetLogger(typeof(CopyHelper)); - public static void Copy(NPath fromPath, NPath toPath) + public static void Copy(SPath fromPath, SPath toPath) { Logger.Trace("Copying from {0} to {1}", fromPath, toPath); @@ -42,7 +42,7 @@ public static void Copy(NPath fromPath, NPath toPath) } } - public static void CopyFolder(NPath fromPath, NPath toPath) + public static void CopyFolder(SPath fromPath, SPath toPath) { Logger.Trace("CopyFolder from {0} to {1}", fromPath, toPath); toPath.DeleteIfExists(); @@ -50,7 +50,7 @@ public static void CopyFolder(NPath fromPath, NPath toPath) fromPath.Move(toPath); } - public static void CopyFolderContents(NPath fromPath, NPath toPath) + public static void CopyFolderContents(SPath fromPath, SPath toPath) { Logger.Trace("CopyFolderContents from {0} to {1}", fromPath, toPath); toPath.DeleteContents(); diff --git a/src/com.spoiledcat.utilities/Editor/Utilities/StreamExtensions.cs b/src/com.spoiledcat.utilities/Editor/Utilities/StreamExtensions.cs index 660b2a1..6aa4040 100644 --- a/src/com.spoiledcat.utilities/Editor/Utilities/StreamExtensions.cs +++ b/src/com.spoiledcat.utilities/Editor/Utilities/StreamExtensions.cs @@ -8,7 +8,7 @@ namespace SpoiledCat.Extensions { using System; - using NiceIO; + using SimpleIO; public static class StreamExtensions { @@ -28,14 +28,14 @@ public static byte[] ToByteArray(this Stream input) } } - public static class NPathExtensions + public static class SPathExtensions { - public static string ToMD5(this NPath path) + public static string ToMD5(this SPath path) { byte[] computeHash; using (var hash = System.Security.Cryptography.MD5.Create()) { - using (var stream = NPath.FileSystem.OpenRead(path)) + using (var stream = SPath.FileSystem.OpenRead(path)) { computeHash = hash.ComputeHash(stream); } @@ -44,12 +44,12 @@ public static string ToMD5(this NPath path) return BitConverter.ToString(computeHash).Replace("-", string.Empty).ToLower(); } - public static string ToSha256(this NPath path) + public static string ToSha256(this SPath path) { byte[] computeHash; using (var hash = System.Security.Cryptography.SHA256.Create()) { - using (var stream = NPath.FileSystem.OpenRead(path)) + using (var stream = SPath.FileSystem.OpenRead(path)) { computeHash = hash.ComputeHash(stream); } diff --git a/src/com.spoiledcat.utilities/Editor/Utilities/Utils.cs b/src/com.spoiledcat.utilities/Editor/Utilities/Utils.cs index 453aa85..0fdb011 100644 --- a/src/com.spoiledcat.utilities/Editor/Utilities/Utils.cs +++ b/src/com.spoiledcat.utilities/Editor/Utilities/Utils.cs @@ -10,7 +10,7 @@ namespace SpoiledCat.Utilities { using Extensions; - using NiceIO; + using SimpleIO; public static class Utils { @@ -89,7 +89,7 @@ public static bool Copy(Stream source, return success; } - public static bool VerifyFileIntegrity(NPath file, string hash) + public static bool VerifyFileIntegrity(SPath file, string hash) { if (!file.IsInitialized || !file.FileExists()) return false; diff --git a/src/com.spoiledcat.utilities/Editor/Utilities/ZipHelper.cs b/src/com.spoiledcat.utilities/Editor/Utilities/ZipHelper.cs index 5ee3481..d61cbf6 100644 --- a/src/com.spoiledcat.utilities/Editor/Utilities/ZipHelper.cs +++ b/src/com.spoiledcat.utilities/Editor/Utilities/ZipHelper.cs @@ -15,7 +15,7 @@ namespace SpoiledCat.Utilities using ICSharpCode.SharpZipLib.Tar; using ICSharpCode.SharpZipLib.Zip; using Logging; - using NiceIO; + using SimpleIO; public interface IZipHelper { @@ -32,15 +32,15 @@ public bool Extract(string archive, string outFolder, CancellationToken cancella Action onStart, Func onProgress, Func onFilter = null) { - var destDir = outFolder.ToNPath(); + var destDir = outFolder.ToSPath(); destDir.EnsureDirectoryExists(); if (archive.EndsWith(".tar.gz")) { - var gzipFile = archive.ToNPath(); + var gzipFile = archive.ToSPath(); - archive = NPath.CreateTempDirectory("git").Combine(gzipFile.FileNameWithoutExtension); - using (var instream = NPath.FileSystem.OpenRead(gzipFile)) - using (var outstream = NPath.FileSystem.OpenWrite(archive, FileMode.CreateNew)) + archive = SPath.CreateTempDirectory("git").Combine(gzipFile.FileNameWithoutExtension); + using (var instream = SPath.FileSystem.OpenRead(gzipFile)) + using (var outstream = SPath.FileSystem.OpenWrite(archive, FileMode.CreateNew)) { GZip.Decompress(instream, outstream, false); } @@ -51,14 +51,14 @@ public bool Extract(string archive, string outFolder, CancellationToken cancella return ExtractZip(archive, destDir, cancellationToken, onStart, onProgress, onFilter); } - private bool ExtractZip(string archive, NPath outFolder, CancellationToken cancellationToken, + private bool ExtractZip(string archive, SPath outFolder, CancellationToken cancellationToken, Action onStart, Func onProgress, Func onFilter = null) { ZipFile zf = null; try { - var fs = NPath.FileSystem.OpenRead(archive); + var fs = SPath.FileSystem.OpenRead(archive); zf = new ZipFile(fs); List entries = PreprocessEntries(outFolder, zf, onStart, onFilter); return ExtractArchive(archive, outFolder, cancellationToken, zf, entries, onStart, onProgress, onFilter); @@ -74,7 +74,7 @@ private bool ExtractZip(string archive, NPath outFolder, CancellationToken cance } } - private bool ExtractTar(string archive, NPath outFolder, CancellationToken cancellationToken, + private bool ExtractTar(string archive, SPath outFolder, CancellationToken cancellationToken, Action onStart, Func onProgress, Func onFilter = null) { TarArchive zf = null; @@ -82,11 +82,11 @@ private bool ExtractTar(string archive, NPath outFolder, CancellationToken cance try { List entries; - using (var read = TarArchive.CreateInputTarArchive(NPath.FileSystem.OpenRead(archive))) + using (var read = TarArchive.CreateInputTarArchive(SPath.FileSystem.OpenRead(archive))) { entries = PreprocessEntries(outFolder, read, onStart, onFilter); } - zf = TarArchive.CreateInputTarArchive(NPath.FileSystem.OpenRead(archive)); + zf = TarArchive.CreateInputTarArchive(SPath.FileSystem.OpenRead(archive)); return ExtractArchive(archive, outFolder, cancellationToken, zf, entries, onStart, onProgress, onFilter); } catch (Exception ex) @@ -100,7 +100,7 @@ private bool ExtractTar(string archive, NPath outFolder, CancellationToken cance } } - private static bool ExtractArchive(string archive, NPath outFolder, CancellationToken cancellationToken, + private static bool ExtractArchive(string archive, SPath outFolder, CancellationToken cancellationToken, IArchive zf, List entries, Action onStart, Func onProgress, Func onFilter = null) { @@ -130,7 +130,7 @@ private static bool ExtractArchive(string archive, NPath outFolder, Cancellation return true; } - private static List PreprocessEntries(NPath outFolder, IArchive zf, Action onStart, Func onFilter) + private static List PreprocessEntries(SPath outFolder, IArchive zf, Action onStart, Func onFilter) { var entries = new List(); @@ -155,13 +155,13 @@ private static List PreprocessEntries(NPath outFolder, IArchive z return entries; } - private static NPath MaybeSetPermissions(NPath destDir, string entryFileName, int mode) + private static SPath MaybeSetPermissions(SPath destDir, string entryFileName, int mode) { var fullZipToPath = destDir.Combine(entryFileName); fullZipToPath.EnsureParentDirectoryExists(); try { - if (NPath.IsUnix && MonoPosixShim.HasMonoPosix) + if (SPath.IsUnix && MonoPosixShim.HasMonoPosix) { if (mode == -2115174400) { diff --git a/src/com.spoiledcat.utilities/Editor/Utilities/com.spoiledcat.utilities.asmdef b/src/com.spoiledcat.utilities/Editor/Utilities/com.spoiledcat.utilities.asmdef index 175c8b4..9fb3a76 100644 --- a/src/com.spoiledcat.utilities/Editor/Utilities/com.spoiledcat.utilities.asmdef +++ b/src/com.spoiledcat.utilities/Editor/Utilities/com.spoiledcat.utilities.asmdef @@ -1,7 +1,7 @@ { "name": "com.spoiledcat.utilities", "references": [ - "com.spoiledcat.niceio", + "com.spoiledcat.simpleio", "com.spoiledcat.logging", "com.spoiledcat.simplejson", "com.spoiledcat.environment", diff --git a/src/com.spoiledcat.utilities/package.json b/src/com.spoiledcat.utilities/package.json index 3005167..bb82b0c 100644 --- a/src/com.spoiledcat.utilities/package.json +++ b/src/com.spoiledcat.utilities/package.json @@ -18,7 +18,7 @@ "dependencies": { "com.spoiledcat.environment": "0.0.0-placeholder", "com.spoiledcat.logging": "0.0.0-placeholder", - "com.spoiledcat.niceio": "0.0.0-placeholder", + "com.spoiledcat.simpleio": "0.0.0-placeholder", "com.spoiledcat.sharpziplib": "0.0.0-placeholder", "com.spoiledcat.simplejson": "0.0.0-placeholder" } diff --git a/tests/Helpers/Helper.CommandLine/Helper.CommandLine.csproj b/tests/Helpers/Helper.CommandLine/Helper.CommandLine.csproj index ca8f8ba..c3d746f 100644 --- a/tests/Helpers/Helper.CommandLine/Helper.CommandLine.csproj +++ b/tests/Helpers/Helper.CommandLine/Helper.CommandLine.csproj @@ -7,7 +7,7 @@ - + diff --git a/tests/Helpers/Helper.CommandLine/Program.cs b/tests/Helpers/Helper.CommandLine/Program.cs index ba8d998..8fecb70 100644 --- a/tests/Helpers/Helper.CommandLine/Program.cs +++ b/tests/Helpers/Helper.CommandLine/Program.cs @@ -9,7 +9,7 @@ using Extensions; using Logging; using Mono.Options; - using NiceIO; + using SimpleIO; using TestWebServer; using Threading; using Utilities; @@ -20,7 +20,7 @@ static class Program private static string ReadAllTextIfFileExists(this string path) { - var file = path.ToNPath(); + var file = path.ToSPath(); if (!file.IsInitialized || !file.FileExists()) { return null; @@ -28,11 +28,11 @@ private static string ReadAllTextIfFileExists(this string path) return file.ReadAllText(); } - private static void RunWebServer(NPath path, int port) + private static void RunWebServer(SPath path, int port) { if (!path.IsInitialized) { - path = typeof(Program).Assembly.Location.ToNPath().Parent.Combine("files"); + path = typeof(Program).Assembly.Location.ToSPath().Parent.Combine("files"); } var evt = new ManualResetEventSlim(false); @@ -59,7 +59,7 @@ private static void RunWebServer(NPath path, int port) private static HttpServer RunWebServer(int port) { - var path = typeof(Program).Assembly.Location.ToNPath().Parent.Combine("files"); + var path = typeof(Program).Assembly.Location.ToSPath().Parent.Combine("files"); var server = new HttpServer(path, port); var thread = new Thread(() => { server.Start(); }); @@ -81,8 +81,8 @@ private static int Main(string[] args) var readInputToEof = false; var lines = new List(); var runWebServer = false; - NPath outfile = NPath.Default; - NPath path = NPath.Default; + SPath outfile = SPath.Default; + SPath path = SPath.Default; string releaseNotes = null; var webServerPort = -1; var generateVersion = false; @@ -118,11 +118,11 @@ private static int Main(string[] args) .Add("v=|version=", v => version = v) .Add("gen-package", "Pass --version --url --path --md5 --rn --msg to generate a package", v => generatePackage = true) .Add("u=|url=", v => url = v) - .Add("path=", v => path = v.ToNPath()) + .Add("path=", v => path = v.ToSPath()) .Add("rn=", "Path to file with release notes", v => releaseNotes = v.ReadAllTextIfFileExists()) .Add("msg=", "Path to file with message for package", v => msg = v.ReadAllTextIfFileExists()) .Add("readVersion=", v => readVersion = v) - .Add("o=|outfile=", v => outfile = v.ToNPath().MakeAbsolute()) + .Add("o=|outfile=", v => outfile = v.ToSPath().MakeAbsolute()) .Add("h=", "Host", v => host = v) .Add("help", v => p.WriteOptionDescriptions(Console.Out)) .Add("b|block", v => block = true) @@ -134,7 +134,7 @@ private static int Main(string[] args) extra.Remove("usage"); p.Parse(extra); - path = extra[extra.Count - 1].ToNPath(); + path = extra[extra.Count - 1].ToSPath(); var server = RunWebServer(webServerPort); var webRequest = (HttpWebRequest)WebRequest.Create(new UriString("http://localhost:" + webServerPort + "/api/usage/unity")); webRequest.Method = "POST"; diff --git a/tests/ProcessManager.Tests/BaseTest.cs b/tests/ProcessManager.Tests/BaseTest.cs index 55badc5..d93a28a 100644 --- a/tests/ProcessManager.Tests/BaseTest.cs +++ b/tests/ProcessManager.Tests/BaseTest.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using System.Threading; using SpoiledCat.Logging; -using SpoiledCat.NiceIO; +using SpoiledCat.SimpleIO; using SpoiledCat.Unity; using SpoiledCat.Threading; using SpoiledCat.ProcessManager; @@ -34,7 +34,7 @@ public void Dispose() protected void StartTest(out Stopwatch watch, out ILogging logger, out ITaskManager taskManager, - out NPath testPath, out IEnvironment environment, out IProcessManager processManager, + out SPath testPath, out IEnvironment environment, out IProcessManager processManager, [CallerMemberName] string testName = "test") { logger = new LogFacade(testName, new NUnitLogAdapter(), TracingEnabled); @@ -42,7 +42,7 @@ protected void StartTest(out Stopwatch watch, out ILogging logger, out ITaskMana taskManager = TaskManager; - testPath = NPath.CreateTempDirectory(testName); + testPath = SPath.CreateTempDirectory(testName); environment = new UnityEnvironment(testName); ((UnityEnvironment)environment).SetWorkingDirectory(testPath); @@ -62,14 +62,14 @@ protected void RunTest(Func testMethodToRun) {} } - protected NPath? testApp; + protected SPath? testApp; - protected NPath TestApp + protected SPath TestApp { get { if (!testApp.HasValue) - testApp = System.Reflection.Assembly.GetExecutingAssembly().Location.ToNPath().Parent.Combine("Helper.CommandLine.exe"); + testApp = System.Reflection.Assembly.GetExecutingAssembly().Location.ToSPath().Parent.Combine("Helper.CommandLine.exe"); return testApp.Value; } } diff --git a/tests/ProcessManager.Tests/ProcessManager.Tests.csproj b/tests/ProcessManager.Tests/ProcessManager.Tests.csproj index cfa375d..595a5bc 100644 --- a/tests/ProcessManager.Tests/ProcessManager.Tests.csproj +++ b/tests/ProcessManager.Tests/ProcessManager.Tests.csproj @@ -24,42 +24,12 @@ - + - - - - - - - - - - - - - - - - - - - - + diff --git a/tests/ProcessManager.Tests/copyhelperbinaries.targets b/tests/ProcessManager.Tests/copyhelperbinaries.targets new file mode 100644 index 0000000..002db5f --- /dev/null +++ b/tests/ProcessManager.Tests/copyhelperbinaries.targets @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/Threading.Tests/BaseTest.cs b/tests/Threading.Tests/BaseTest.cs index 8bf62b4..e27e2d0 100644 --- a/tests/Threading.Tests/BaseTest.cs +++ b/tests/Threading.Tests/BaseTest.cs @@ -6,7 +6,7 @@ using System.Threading; using SpoiledCat.Logging; -using SpoiledCat.NiceIO; +using SpoiledCat.SimpleIO; using SpoiledCat.Threading; namespace BaseTests diff --git a/tests/Threading.Tests/Threading.Tests.csproj b/tests/Threading.Tests/Threading.Tests.csproj index c1a0c98..48a92eb 100644 --- a/tests/Threading.Tests/Threading.Tests.csproj +++ b/tests/Threading.Tests/Threading.Tests.csproj @@ -15,7 +15,7 @@ - +