Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion FileUtilities/DataLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,36 @@ public static bool TryFindFullPath(string filePath, DataLocation location,
return false;
}

/// <summary>
/// Attempts to find the full directory path for the passed in DataLocation
/// </summary>
/// <param name="location">The data location type to try to find a directory path for</param>
/// <param name="directoryPath">The full data path to the desired data location</param>
/// <typeparam name="TLoader">The data loader to get a data location from</typeparam>
/// <returns>True if the directory was found for the desired loader type, otherwise false</returns>
public static bool TryGetLocationPath<TLoader>(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;
}

/// <summary>
/// Helper function used to load JSON data from a file path
/// </summary>
Expand Down Expand Up @@ -517,4 +547,4 @@ private static bool ReadAllXml(string filePath,
data = rootNode.ChildNodes;
return true;
}
}
}
4 changes: 2 additions & 2 deletions FileUtilities/FileUtilities.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<Title>FileUtilities</Title>
<Authors>FluffyVoid</Authors>
<Description>Collection of file IO utilities including the Data Loader framework that can load file data from user defined data locations. </Description>
<AssemblyVersion>1.0.3</AssemblyVersion>
<FileVersion>1.0.3</FileVersion>
<AssemblyVersion>1.0.4</AssemblyVersion>
<FileVersion>1.0.4</FileVersion>
<Product>FluffyVoid.FileUtilities</Product>
<RepositoryUrl>https://github.com/ashiryn/FileUtilities</RepositoryUrl>
</PropertyGroup>
Expand Down