mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-12 15:07:23 +01:00
27 lines
751 B
C#
27 lines
751 B
C#
namespace MareSynchronosStaticFilesServer;
|
|
|
|
public static class FilePathUtil
|
|
{
|
|
public static FileInfo? GetFileInfoForHash(string basePath, string hash)
|
|
{
|
|
FileInfo fi = new(Path.Combine(basePath, hash[0].ToString(), hash));
|
|
if (!fi.Exists)
|
|
{
|
|
fi = new FileInfo(Path.Combine(basePath, hash));
|
|
if (!fi.Exists)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
return fi;
|
|
}
|
|
|
|
public static string GetFilePath(string basePath, string hash)
|
|
{
|
|
var dirPath = Path.Combine(basePath, hash[0].ToString());
|
|
var path = Path.Combine(dirPath, hash);
|
|
if (!Directory.Exists(dirPath)) Directory.CreateDirectory(dirPath);
|
|
return path;
|
|
}
|
|
}
|