Filesystem bugfixes

This commit is contained in:
Timerix22 2023-04-05 03:33:35 +06:00
parent 2db018c54b
commit bb55c69108
8 changed files with 25 additions and 18 deletions

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<!--package info-->
<PackageId>DTLib.Dtsod</PackageId>
<Version>1.2.0</Version>
<Version>1.2.1</Version>
<Authors>Timerix</Authors>
<Description>Definitely not json</Description>
<RepositoryType>GIT</RepositoryType>
@ -33,7 +33,7 @@
<ProjectReference Include="..\DTLib\DTLib.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
<PackageReference Include="DTLib" Version="1.2.0" />
<PackageReference Include="DTLib" Version="1.2.2" />
</ItemGroup>
<!--project files-->

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<!--package info-->
<PackageId>DTLib.Logging</PackageId>
<Version>1.2.0</Version>
<Version>1.2.1</Version>
<Authors>Timerix</Authors>
<Description>Loggers with dependency injection</Description>
<RepositoryType>GIT</RepositoryType>
@ -30,7 +30,7 @@
<ProjectReference Include="..\DTLib.Ben.Demystifier\DTLib.Ben.Demystifier.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
<PackageReference Include="DTLib" Version="1.2.0" />
<PackageReference Include="DTLib" Version="1.2.2" />
<PackageReference Include="DTLib.Ben.Demystifier" Version="1.0.4" />
</ItemGroup>
</Project>

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<!--package info-->
<PackageId>DTLib.Network</PackageId>
<Version>1.2.0</Version>
<Version>1.2.1</Version>
<Authors>Timerix</Authors>
<Description>Some sick network protocols</Description>
<RepositoryType>GIT</RepositoryType>

View File

@ -27,7 +27,7 @@
<ProjectReference Include="..\DTLib\DTLib.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
<PackageReference Include="DTLib" Version="1.2.0" />
<PackageReference Include="DTLib" Version="1.2.2" />
<PackageReference Include="DTLib.Dtsod" Version="1.1.5" />
<PackageReference Include="DTLib.Network" Version="1.1.5" />
<PackageReference Include="DTLib.Logging" Version="1.1.5" />

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<!--package info-->
<PackageId>DTLib</PackageId>
<Version>1.2.1</Version>
<Version>1.2.2</Version>
<Authors>Timerix</Authors>
<Description>Library for all my C# projects</Description>
<RepositoryType>GIT</RepositoryType>

View File

@ -54,6 +54,7 @@ public static class Directory
Delete(target_path);
else throw new Exception($"directory {target_path} already exists");
}
else Directory.Create(target_path.ParentDir());
System.IO.Directory.Move(current_path.Str, target_path.Str);
}
@ -62,16 +63,16 @@ public static class Directory
System.IO.Directory.Delete(dir.Str, true);
public static IOPath[] GetFiles(IOPath dir) =>
IOPath.ArrayCast(System.IO.Directory.GetFiles(dir.Str));
IOPath.ArrayCast(System.IO.Directory.GetFiles(dir.Str), true);
public static IOPath[] GetFiles(IOPath dir, string searchPattern) =>
IOPath.ArrayCast(System.IO.Directory.GetFiles(dir.Str, searchPattern));
IOPath.ArrayCast(System.IO.Directory.GetFiles(dir.Str, searchPattern), true);
public static IOPath[] GetDirectories(IOPath dir) =>
IOPath.ArrayCast(System.IO.Directory.GetDirectories(dir.Str));
IOPath.ArrayCast(System.IO.Directory.GetDirectories(dir.Str), true);
public static IOPath[] GetDirectories(IOPath dir, string searchPattern) =>
IOPath.ArrayCast(System.IO.Directory.GetDirectories(dir.Str, searchPattern));
IOPath.ArrayCast(System.IO.Directory.GetDirectories(dir.Str, searchPattern), true);
/// выдает список всех файлов
public static List<IOPath> GetAllFiles(IOPath dir)

View File

@ -45,6 +45,7 @@ public static class File
Delete(target_path);
else throw new Exception($"file {target_path} already exists");
}
else Directory.Create(target_path.ParentDir());
System.IO.File.Move(current_path.Str, target_path.Str);
}

View File

@ -40,18 +40,18 @@ public readonly struct IOPath
return new string(fixed_path);
}
public static IOPath[] ArrayCast(string[] a)
public static IOPath[] ArrayCast(string[] a, bool correct_separators=false)
{
IOPath[] b = new IOPath[a.Length];
for (int i = 0; i < a.Length; i++)
b[i] = (IOPath)a[i];
for (int i = 0; i < a.Length; i++)
b[i] = new IOPath(a[i], correct_separators);
return b;
}
public static IOPath[] ListCast(IList<string> a)
public static IOPath[] ListCast(IList<string> a, bool correct_separators=false)
{
IOPath[] b = new IOPath[a.Count];
for (int i = 0; i < a.Count; i++)
b[i] = (IOPath)a[i];
for (int i = 0; i < a.Count; i++)
b[i] = new IOPath(a[i], correct_separators);
return b;
}
@ -62,7 +62,12 @@ public readonly struct IOPath
public static implicit operator IOPath(string s) => new(s);
public static explicit operator string(IOPath p) => p.Str;
public override string ToString() => Str;
public override bool Equals(object obj) => Str.Equals(obj);
public override bool Equals(object obj)
{
if (obj is null) return false;
return Str == obj.ToString();
}
public override int GetHashCode() => Str.GetHashCode();
public char this[int i] => Str[i];