zxl 2024-12-20 09:10:03 +08:00
commit b18c8ddf08
13 changed files with 240 additions and 10 deletions

2
.gitignore vendored
View File

@ -3,6 +3,7 @@
.idea/
.vscode/
_ReSharper.CSharp/
.sln
#svn
*/.svn/
@ -41,3 +42,4 @@ obj/
Temp/
yoo
/Assets/DemoGame/GameScript/Hotfix/Generate
/Packages

View File

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

View File

@ -0,0 +1,42 @@
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 override FileSystemInfoType FileSystemInfoType { get; }
public DirectoryInfo Parent
{
get
{
var parentPath = FullPath.Split("\\")[^1];
var directoryInfo = new DirectoryInfo(System.IO.Path.GetFullPath(parentPath));
return directoryInfo;
}
}
public DirectoryInfo Root => new DirectoryInfo(System.IO.Path.GetPathRoot(this.FullPath));
public DirectoryInfo(string path)
{
FullPath = System.IO.Path.GetFullPath(path);
_name = System.IO.Path.GetDirectoryName(path);
}
// 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,31 @@
using System;
using System.IO;
namespace ZXLT.FileSystem
{
public sealed class FileInfo : FileSystemInfo
{
public string Extension => Path.GetExtension(this.FullName);
public override bool Exists { get; }
public override string Name => _name;
public override FileSystemInfoType FileSystemInfoType { get; }
public string? DirectoryName => Path.GetDirectoryName(this.FullPath);
public DirectoryInfo Directory
{
get
{
string directoryName = this.DirectoryName;
return new DirectoryInfo(directoryName);
}
}
public FileInfo(string fileName)
{
fileName = fileName ?? throw new ArgumentNullException(nameof(fileName));
_name = Path.GetFileName(fileName);
this.FullPath = Path.GetFullPath(fileName);
FileSystemInfoType = FileSystemInfoType.File;
}
}
}

View File

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

View File

@ -0,0 +1,126 @@
using System;
using System.Collections.Generic;
using ZXL.Helper;
namespace ZXLT.FileSystem
{
class FileBase
{
}
class Directory : FileBase
{
DirectoryInfo directoryInfo;
List<Directory> directories = new List<Directory>();
List<File> files = new List<File>();
public Directory(DirectoryInfo directoryInfo)
{
this.directoryInfo = directoryInfo;
}
public void AddDirectory(Directory dir)
{
directories.Add(dir);
}
public void AddFile(File file)
{
files.Add(file);
}
public void RemoveDirectory(Directory dir)
{
directories.Remove(dir);
}
public void RemoveFile(File file)
{
files.Remove(file);
}
public void Clear()
{
directories.Clear();
}
}
class File : FileBase
{
FileInfo fileInfo;
public File(FileInfo fileInfo)
{
this.fileInfo = fileInfo;
}
}
interface IFileSystem
{
event Action<FileSystemInfo> OnUpdateFileSystem;
void CreateDirectory(string path);
void DeleteDirectory(string path);
void DeleteFile(string path);
void MoveDirectory(string sourcePath, string destPath);
void MoveFile(string sourcePath, string destPath);
void RenameDirectory(string sourcePath, string destPath);
void RenameFile(string sourcePath, string destPath);
}
public class FileSystem : IFileSystem
{
Directory rootDirectory;
SortedDictionary<string, FileBase> fileBases = new SortedDictionary<string, FileBase>();
public event Action<FileSystemInfo> OnUpdateFileSystem;
void UpdateFileSystem(FileSystemInfo systemInfo)
{
OnUpdateFileSystem?.Invoke(systemInfo);
}
public void CreateDirectory(string path)
{
var directory = new Directory(new DirectoryInfo(path));
fileBases.Add(path, directory);
FileHelper.CreateDirectory(path);
}
public void CreateFile(string path)
{
var file = new File(new FileInfo(path));
fileBases.Add(path, file);
FileHelper.CreateDirectory(path);
}
public void DeleteDirectory(string path)
{
throw new NotImplementedException();
}
public void DeleteFile(string path)
{
throw new NotImplementedException();
}
public void MoveDirectory(string sourcePath, string destPath)
{
throw new NotImplementedException();
}
public void MoveFile(string sourcePath, string destPath)
{
throw new NotImplementedException();
}
public void RenameDirectory(string sourcePath, string destPath)
{
throw new NotImplementedException();
}
public void RenameFile(string sourcePath, string destPath)
{
throw new NotImplementedException();
}
}
}

View File

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

View File

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

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>