From 616de76d312558e44426ec4f77863844ce5d8001 Mon Sep 17 00:00:00 2001 From: Joe Thompson Date: Sat, 7 Feb 2026 15:58:26 -0500 Subject: [PATCH] Added function to allow retrieval of a data location path from a desired data loader path --- FileUtilities/DataLoader.cs | 32 +++++++++++++++++++++++++++++- FileUtilities/FileUtilities.csproj | 4 ++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/FileUtilities/DataLoader.cs b/FileUtilities/DataLoader.cs index ffa25ce..f6634c0 100644 --- a/FileUtilities/DataLoader.cs +++ b/FileUtilities/DataLoader.cs @@ -374,6 +374,36 @@ public static bool TryFindFullPath(string filePath, DataLocation location, return false; } + /// + /// Attempts to find the full directory path for the passed in DataLocation + /// + /// The data location type to try to find a directory path for + /// The full data path to the desired data location + /// The data loader to get a data location from + /// True if the directory was found for the desired loader type, otherwise false + public static bool TryGetLocationPath(DataLocation location, out string directoryPath) + { + if (s_primaryDataLoaderPath is TLoader) + { + directoryPath = $"{s_primaryDataLoaderPath.GetDataPath(location)}"; + + return true; + } + + foreach (IDataLoaderPath fallbackPath in FallbackDataLoaderPaths) + { + if (fallbackPath is TLoader) + { + directoryPath = $"{fallbackPath.GetDataPath(location)}"; + + return true; + } + } + + directoryPath = string.Empty; + return false; + } + /// /// Helper function used to load JSON data from a file path /// @@ -517,4 +547,4 @@ private static bool ReadAllXml(string filePath, data = rootNode.ChildNodes; return true; } -} \ No newline at end of file +} diff --git a/FileUtilities/FileUtilities.csproj b/FileUtilities/FileUtilities.csproj index 54ed9f9..f6d2c57 100644 --- a/FileUtilities/FileUtilities.csproj +++ b/FileUtilities/FileUtilities.csproj @@ -11,8 +11,8 @@ FileUtilities FluffyVoid Collection of file IO utilities including the Data Loader framework that can load file data from user defined data locations. - 1.0.3 - 1.0.3 + 1.0.4 + 1.0.4 FluffyVoid.FileUtilities https://github.com/ashiryn/FileUtilities