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

35 lines
1.1 KiB
C#

using System;
using System.IO;
namespace ZXLT.FileSystem
{
public sealed class FileInfo : FileSystemInfo
{
public string Extension { get; }
public override bool Exists { get; }
public override string Name => _name;
public string? DirectoryName => Path.GetDirectoryName(this.FullPath);
public DirectoryInfo Directory
{
get
{
string directoryName = this.DirectoryName;
return new DirectoryInfo(directoryName);
}
}
public FileInfo(string fileName)
: this(fileName ?? throw new ArgumentNullException(nameof(fileName)), (string)null, (string)null, false)
{
}
internal FileInfo(string originalPath, string fullPath = null, string fileName = null, bool isNormalized = false)
{
if (fullPath == null)
fullPath = originalPath;
this.FullPath = isNormalized ? fullPath ?? originalPath : Path.GetFullPath(fullPath);
this._name = fileName;
}
}
}