EditorTool3D/Assets/ZXL/Scripts/FileSystem/DirectoryInfo.cs

42 lines
1.2 KiB
C#
Raw Normal View History

2024-12-18 23:46:42 +08:00
using System.Collections.Generic;
namespace ZXLT.FileSystem
{
public sealed class DirectoryInfo : FileSystemInfo
{
2024-12-19 23:07:52 +08:00
// List<DirectoryInfo> directories = new List<DirectoryInfo>();
// List<FileInfo> files = new List<FileInfo>();
2024-12-18 23:46:42 +08:00
public override bool Exists { get; }
public override string Name => _name;
2024-12-19 23:07:52 +08:00
public override FileSystemInfoType FileSystemInfoType { get; }
2024-12-18 23:46:42 +08:00
public DirectoryInfo Parent
{
get
{
2024-12-19 23:07:52 +08:00
var parentPath = FullPath.Split("\\")[^1];
var directoryInfo = new DirectoryInfo(System.IO.Path.GetFullPath(parentPath));
2024-12-18 23:46:42 +08:00
return directoryInfo;
}
}
public DirectoryInfo Root => new DirectoryInfo(System.IO.Path.GetPathRoot(this.FullPath));
public DirectoryInfo(string path)
{
2024-12-19 23:07:52 +08:00
FullPath = System.IO.Path.GetFullPath(path);
_name = System.IO.Path.GetDirectoryName(path);
2024-12-18 23:46:42 +08:00
}
2024-12-19 23:07:52 +08:00
// public DirectoryInfo[] GetDirectories()
// {
// return directories.ToArray();
// }
//
// public FileInfo[] GetFiles()
// {
// return files.ToArray();
// }
2024-12-18 23:46:42 +08:00
}
}