修改:重写文件系统

master
zc 2024-12-18 23:46:42 +08:00
parent fb4d44c5eb
commit 1692f02643
12 changed files with 124 additions and 10 deletions

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4df538268f04411baf7e6ed3f6f30196
timeCreated: 1734530869

View File

@ -0,0 +1,50 @@
using System.Collections.Generic;
namespace ZXLT.FileSystem
{
public sealed class DirectoryInfo : FileSystemInfo
{
List<DirectoryInfo> directories = new List<DirectoryInfo>();
List<FileInfo> files = new List<FileInfo>();
public override bool Exists { get; }
public override string Name => _name;
public DirectoryInfo Parent
{
get
{
var directoryInfo = new DirectoryInfo(System.IO.Path.GetDirectoryName(FullPath));
return directoryInfo;
}
}
public DirectoryInfo Root => new DirectoryInfo(System.IO.Path.GetPathRoot(this.FullPath));
public DirectoryInfo(string path)
{
this.Init(path, System.IO.Path.GetFullPath(path), isNormalized: true);
FullPath = path;
_name = path;
}
private void Init(string originalPath, string fullPath = null, string fileName = null, bool isNormalized = false)
{
if (fullPath == null)
fullPath = originalPath;
fullPath = isNormalized ? fullPath : System.IO.Path.GetFullPath(fullPath);
this._name = fileName;
this.FullPath = fullPath;
}
public DirectoryInfo[] GetDirectories()
{
return directories.ToArray();
}
public FileInfo[] GetFiles()
{
return files.ToArray();
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 65370db5c69842b881243c312e0c3ce2
timeCreated: 1734532009

View File

@ -0,0 +1,35 @@
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;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: fdedcd6447e4414195754ba8f1f67072
timeCreated: 1734532019

View File

@ -0,0 +1,7 @@
namespace ZXLT.FileSystem
{
public class FileSystem
{
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a1c6853ef5a44b3986a6a3854cc7ac1d
timeCreated: 1734530888

View File

@ -0,0 +1,14 @@
using System;
namespace ZXLT.FileSystem
{
public abstract class FileSystemInfo
{
protected string _name;
protected string FullPath;
public DateTime CreationTime { get; set; }
public abstract bool Exists { get; }
public abstract string Name { get; }
public virtual string FullName => FullPath;
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f977646b313a4fa3a7a98a2454009041
timeCreated: 1734532034

View File

@ -1,7 +0,0 @@
namespace ZXL.Manager
{
public class ZFileSystem
{
}
}

View File

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 63f2843889a64090a60431d1d84b908c
timeCreated: 1734501412

View File

@ -1,4 +1,7 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADirectoryInfo_002Ecs_002Fl_003AC_0021_003FUsers_003FAdministrator_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F5a41d6b7189842eca409fd0b1c3e3dcf17bf78_003Fb9_003F5b634a7f_003FDirectoryInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADirectoryInfo_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003F10628_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F5a41d6b7189842eca409fd0b1c3e3dcf17bf78_003Fb9_003F5b634a7f_003FDirectoryInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFileInfo_002Ecs_002Fl_003AC_0021_003FUsers_003FAdministrator_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F5a41d6b7189842eca409fd0b1c3e3dcf17bf78_003Fe1_003Fb009330d_003FFileInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFileInfo_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003F10628_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F5a41d6b7189842eca409fd0b1c3e3dcf17bf78_003Fe1_003Fb009330d_003FFileInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFileSystemInfo_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003F10628_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F5a41d6b7189842eca409fd0b1c3e3dcf17bf78_003F5b_003F407d31d8_003FFileSystemInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASortedDictionary_00602_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003F10628_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F5a41d6b7189842eca409fd0b1c3e3dcf17bf78_003F9b_003Fdfd6117f_003FSortedDictionary_00602_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>