45 lines
1.1 KiB (Stored with Git LFS)
C#
45 lines
1.1 KiB (Stored with Git LFS)
C#
using System.IO;
|
|
using UnityEditor;
|
|
|
|
namespace DDD
|
|
{
|
|
public static class Utils
|
|
{
|
|
public static string FixPath(string path)
|
|
{
|
|
path = path.Replace('\\', '/');
|
|
path = path.Replace("//", "/");
|
|
while (path.Length > 0 && path[0] == '/')
|
|
{
|
|
path = path.Remove(0, 1);
|
|
}
|
|
return path;
|
|
}
|
|
|
|
public static string FileName(string path)
|
|
{
|
|
return Path.GetFileNameWithoutExtension(path);
|
|
}
|
|
|
|
public static string FolderPath(string path)
|
|
{
|
|
return FixPath(Path.GetDirectoryName(path));
|
|
}
|
|
|
|
public static void MakeFolderFromFilePath(string filePath)
|
|
{
|
|
var paths = FixPath(filePath).Split('/');
|
|
var path = "";
|
|
|
|
for (var i = 0; i < paths.Length - 1; ++i)
|
|
{
|
|
path += paths[i] + "/";
|
|
if (Directory.Exists(path) == false)
|
|
{
|
|
Directory.CreateDirectory(path);
|
|
AssetDatabase.Refresh();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |