quick fix of files path
This commit is contained in:
parent
749b5f1af1
commit
5e75552199
3
.gitignore
vendored
3
.gitignore
vendored
@ -5,4 +5,5 @@
|
|||||||
[Ll]og/
|
[Ll]og/
|
||||||
[Ll]ogs/
|
[Ll]ogs/
|
||||||
.vs/
|
.vs/
|
||||||
.vshistory/
|
.vshistory/
|
||||||
|
.idea/
|
||||||
26
.vscode/launch.json
vendored
26
.vscode/launch.json
vendored
@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
// Use IntelliSense to find out which attributes exist for C# debugging
|
|
||||||
// Use hover for the description of the existing attributes
|
|
||||||
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
|
|
||||||
"name": ".NET Core Launch (console)",
|
|
||||||
"type": "coreclr",
|
|
||||||
"request": "launch",
|
|
||||||
"preLaunchTask": "build",
|
|
||||||
// If you have changed target frameworks, make sure to update the program path.
|
|
||||||
"program": "${workspaceFolder}/TestProgram/bin/Debug/net6.0/TestProgram.dll",
|
|
||||||
"args": [],
|
|
||||||
"cwd": "${workspaceFolder}/TestProgram",
|
|
||||||
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
|
|
||||||
"console": "internalConsole",
|
|
||||||
"stopAtEntry": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": ".NET Core Attach",
|
|
||||||
"type": "coreclr",
|
|
||||||
"request": "attach"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
42
.vscode/tasks.json
vendored
42
.vscode/tasks.json
vendored
@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "2.0.0",
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"label": "build",
|
|
||||||
"command": "dotnet",
|
|
||||||
"type": "process",
|
|
||||||
"args": [
|
|
||||||
"build",
|
|
||||||
"${workspaceFolder}/TestProgram/TestProgram.csproj",
|
|
||||||
"/property:GenerateFullPaths=true",
|
|
||||||
"/consoleloggerparameters:NoSummary"
|
|
||||||
],
|
|
||||||
"problemMatcher": "$msCompile"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "publish",
|
|
||||||
"command": "dotnet",
|
|
||||||
"type": "process",
|
|
||||||
"args": [
|
|
||||||
"publish",
|
|
||||||
"${workspaceFolder}/TestProgram/TestProgram.csproj",
|
|
||||||
"/property:GenerateFullPaths=true",
|
|
||||||
"/consoleloggerparameters:NoSummary"
|
|
||||||
],
|
|
||||||
"problemMatcher": "$msCompile"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "watch",
|
|
||||||
"command": "dotnet",
|
|
||||||
"type": "process",
|
|
||||||
"args": [
|
|
||||||
"watch",
|
|
||||||
"run",
|
|
||||||
"${workspaceFolder}/TestProgram/TestProgram.csproj",
|
|
||||||
"/property:GenerateFullPaths=true",
|
|
||||||
"/consoleloggerparameters:NoSummary"
|
|
||||||
],
|
|
||||||
"problemMatcher": "$msCompile"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@ -10,8 +10,8 @@ public static class Directory
|
|||||||
if (!Directory.Exists(dir))
|
if (!Directory.Exists(dir))
|
||||||
{
|
{
|
||||||
// проверяет существование папки, в которой нужно создать dir
|
// проверяет существование папки, в которой нужно создать dir
|
||||||
if (dir.Contains('\\') && !Directory.Exists(dir.Remove(dir.LastIndexOf('\\'))))
|
if (dir.Contains(Path.Sep) && !Directory.Exists(dir.Remove(dir.LastIndexOf(Path.Sep))))
|
||||||
Create(dir.Remove(dir.LastIndexOf('\\')));
|
Create(dir.Remove(dir.LastIndexOf(Path.Sep)));
|
||||||
System.IO.Directory.CreateDirectory(dir);
|
System.IO.Directory.CreateDirectory(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,8 +100,8 @@ public static class Directory
|
|||||||
|
|
||||||
public static void CreateSymlink(string sourceName, string symlinkName)
|
public static void CreateSymlink(string sourceName, string symlinkName)
|
||||||
{
|
{
|
||||||
if (symlinkName.Contains("\\"))
|
if (symlinkName.Contains(Path.Sep))
|
||||||
Directory.Create(symlinkName.Remove(symlinkName.LastIndexOf('\\')));
|
Directory.Create(symlinkName.Remove(symlinkName.LastIndexOf(Path.Sep)));
|
||||||
if (!Symlink.CreateSymbolicLink(symlinkName, sourceName, Symlink.SymlinkTarget.Directory))
|
if (!Symlink.CreateSymbolicLink(symlinkName, sourceName, Symlink.SymlinkTarget.Directory))
|
||||||
throw new InvalidOperationException($"some error occured while creating symlink\nDirectory.CreateSymlink({symlinkName}, {sourceName})");
|
throw new InvalidOperationException($"some error occured while creating symlink\nDirectory.CreateSymlink({symlinkName}, {sourceName})");
|
||||||
}
|
}
|
||||||
@ -110,8 +110,8 @@ public static class Directory
|
|||||||
public static int SymCopy(string srcdir, string newdir)
|
public static int SymCopy(string srcdir, string newdir)
|
||||||
{
|
{
|
||||||
List<string> files = Directory.GetAllFiles(srcdir);
|
List<string> files = Directory.GetAllFiles(srcdir);
|
||||||
if (!srcdir.EndsWith('\\')) srcdir += '\\';
|
if (!srcdir.EndsWith(Path.Sep)) srcdir += Path.Sep;
|
||||||
if (!newdir.EndsWith('\\')) newdir += '\\';
|
if (!newdir.EndsWith(Path.Sep)) newdir += Path.Sep;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (; i < files.Count; i++)
|
for (; i < files.Count; i++)
|
||||||
File.CreateSymlink(files[i], files[i].Replace(srcdir, newdir));
|
File.CreateSymlink(files[i], files[i].Replace(srcdir, newdir));
|
||||||
|
|||||||
@ -7,14 +7,12 @@ public static class File
|
|||||||
public static bool Exists(string file) => System.IO.File.Exists(file);
|
public static bool Exists(string file) => System.IO.File.Exists(file);
|
||||||
|
|
||||||
// если файл не существует, создаёт файл, создаёт папки из его пути
|
// если файл не существует, создаёт файл, создаёт папки из его пути
|
||||||
public static void Create(string file, bool delete_old = false)
|
public static void Create(string file)
|
||||||
{
|
{
|
||||||
if (delete_old && File.Exists(file))
|
|
||||||
File.Delete(file);
|
|
||||||
if (!File.Exists(file))
|
if (!File.Exists(file))
|
||||||
{
|
{
|
||||||
if (file.Contains("\\"))
|
if (file.Contains(Path.Sep))
|
||||||
Directory.Create(file.Remove(file.LastIndexOf('\\')));
|
Directory.Create(file.Remove(file.LastIndexOf(Path.Sep)));
|
||||||
using System.IO.FileStream stream = System.IO.File.Create(file);
|
using System.IO.FileStream stream = System.IO.File.Create(file);
|
||||||
stream.Close();
|
stream.Close();
|
||||||
}
|
}
|
||||||
@ -64,7 +62,9 @@ public static class File
|
|||||||
Exists(file) ? System.IO.File.OpenRead(file) : throw new Exception($"file not found: <{file}>");
|
Exists(file) ? System.IO.File.OpenRead(file) : throw new Exception($"file not found: <{file}>");
|
||||||
public static System.IO.FileStream OpenWrite(string file)
|
public static System.IO.FileStream OpenWrite(string file)
|
||||||
{
|
{
|
||||||
File.Create(file, true);
|
if (File.Exists(file))
|
||||||
|
File.Delete(file);
|
||||||
|
File.Create(file);
|
||||||
return System.IO.File.Open(file, System.IO.FileMode.OpenOrCreate);
|
return System.IO.File.Open(file, System.IO.FileMode.OpenOrCreate);
|
||||||
}
|
}
|
||||||
public static System.IO.FileStream OpenAppend(string file)
|
public static System.IO.FileStream OpenAppend(string file)
|
||||||
@ -75,8 +75,8 @@ public static class File
|
|||||||
|
|
||||||
public static void CreateSymlink(string sourceName, string symlinkName)
|
public static void CreateSymlink(string sourceName, string symlinkName)
|
||||||
{
|
{
|
||||||
if (symlinkName.Contains("\\"))
|
if (symlinkName.Contains(Path.Sep))
|
||||||
Directory.Create(symlinkName.Remove(symlinkName.LastIndexOf('\\')));
|
Directory.Create(symlinkName.Remove(symlinkName.LastIndexOf(Path.Sep)));
|
||||||
if (!Symlink.CreateSymbolicLink(symlinkName, sourceName, Symlink.SymlinkTarget.File))
|
if (!Symlink.CreateSymbolicLink(symlinkName, sourceName, Symlink.SymlinkTarget.File))
|
||||||
throw new InvalidOperationException($"some error occured while creating symlink\nFile.CreateSymlink({symlinkName}, {sourceName})");
|
throw new InvalidOperationException($"some error occured while creating symlink\nFile.CreateSymlink({symlinkName}, {sourceName})");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,15 +5,6 @@
|
|||||||
//
|
//
|
||||||
public static class OldFilework
|
public static class OldFilework
|
||||||
{
|
{
|
||||||
// записывает текст в файл и закрывает файл
|
|
||||||
/*public static void LogToFile(string logfile, string msg)
|
|
||||||
{
|
|
||||||
lock (new object())
|
|
||||||
{
|
|
||||||
File.AppendAllText(logfile, msg);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// чтение параметров из конфига
|
// чтение параметров из конфига
|
||||||
public static string ReadFromConfig(string configfile, string key)
|
public static string ReadFromConfig(string configfile, string key)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,15 +2,16 @@ namespace DTLib.Filesystem;
|
|||||||
|
|
||||||
static public class Path
|
static public class Path
|
||||||
{
|
{
|
||||||
|
static public readonly char Sep = OperatingSystem.IsWindows() ? '\\' : '/';
|
||||||
|
|
||||||
public static string CorrectSeparator(string path)
|
public static string CorrectSeparator(string path)
|
||||||
{
|
{
|
||||||
if (System.IO.Path.PathSeparator == '\\')
|
if (Sep == '\\')
|
||||||
{
|
{
|
||||||
if (path.Contains('/'))
|
if (path.Contains('/'))
|
||||||
path = path.Replace('/', '\\');
|
path = path.Replace('/', '\\');
|
||||||
}
|
}
|
||||||
else if (System.IO.Path.PathSeparator == '/')
|
else if (Sep == '/')
|
||||||
{
|
{
|
||||||
if (path.Contains('\\'))
|
if (path.Contains('\\'))
|
||||||
path = path.Replace('\\', '/');
|
path = path.Replace('\\', '/');
|
||||||
|
|||||||
@ -20,7 +20,7 @@ public static class TestDtsodV23
|
|||||||
public static void TestBaseTypes()
|
public static void TestBaseTypes()
|
||||||
{
|
{
|
||||||
Info.Log("b", "[TestDtsodV23/TestBaseTypes]");
|
Info.Log("b", "[TestDtsodV23/TestBaseTypes]");
|
||||||
DtsodV23 dtsod = new(File.ReadAllText("DtsodV2X\\base_types.dtsod"));
|
DtsodV23 dtsod = new(File.ReadAllText($"DtsodV2X{Path.Sep}base_types.dtsod"));
|
||||||
foreach (var pair in dtsod)
|
foreach (var pair in dtsod)
|
||||||
Info.LogNoTime("b", pair.Value.GetType().Name + ' ', "w", pair.Key + ' ', "c", pair.Value.ToString());
|
Info.LogNoTime("b", pair.Value.GetType().Name + ' ', "w", pair.Key + ' ', "c", pair.Value.ToString());
|
||||||
Info.Log("g", "[test completed]");
|
Info.Log("g", "[test completed]");
|
||||||
@ -28,7 +28,7 @@ public static class TestDtsodV23
|
|||||||
public static void TestLists()
|
public static void TestLists()
|
||||||
{
|
{
|
||||||
Info.Log("b", "[TestDtsodV23/TestLists]");
|
Info.Log("b", "[TestDtsodV23/TestLists]");
|
||||||
DtsodV23 dtsod = new(File.ReadAllText("DtsodV2X\\lists.dtsod"));
|
DtsodV23 dtsod = new(File.ReadAllText($"DtsodV2X{Path.Sep}lists.dtsod"));
|
||||||
foreach (var pair in dtsod)
|
foreach (var pair in dtsod)
|
||||||
{
|
{
|
||||||
Info.LogNoTime("b", pair.Value.GetType().Name + ' ', "w", pair.Key, "c",
|
Info.LogNoTime("b", pair.Value.GetType().Name + ' ', "w", pair.Key, "c",
|
||||||
@ -42,7 +42,7 @@ public static class TestDtsodV23
|
|||||||
public static void TestComplexes()
|
public static void TestComplexes()
|
||||||
{
|
{
|
||||||
Info.Log("b", "[TestDtsodV23/TestComplexes]");
|
Info.Log("b", "[TestDtsodV23/TestComplexes]");
|
||||||
DtsodV23 dtsod = new(File.ReadAllText("DtsodV2X\\complexes.dtsod"));
|
DtsodV23 dtsod = new(File.ReadAllText($"DtsodV2X{Path.Sep}complexes.dtsod"));
|
||||||
foreach (var pair in dtsod)
|
foreach (var pair in dtsod)
|
||||||
{
|
{
|
||||||
Info.LogNoTime("b", pair.Value.GetType().Name + ' ', "w", pair.Key,
|
Info.LogNoTime("b", pair.Value.GetType().Name + ' ', "w", pair.Key,
|
||||||
@ -56,7 +56,7 @@ public static class TestDtsodV23
|
|||||||
{
|
{
|
||||||
Info.Log("b", "[TestDtsodV23/TestReSerialization]");
|
Info.Log("b", "[TestDtsodV23/TestReSerialization]");
|
||||||
DtsodV23 dtsod = new DtsodV23(new DtsodV23(new DtsodV23(
|
DtsodV23 dtsod = new DtsodV23(new DtsodV23(new DtsodV23(
|
||||||
new DtsodV23(File.ReadAllText("DtsodV2X\\complexes.dtsod")).ToString()).ToString()).ToString());
|
new DtsodV23(File.ReadAllText($"DtsodV2X{Path.Sep}complexes.dtsod")).ToString()).ToString()).ToString());
|
||||||
Info.Log("y", dtsod.ToString());
|
Info.Log("y", dtsod.ToString());
|
||||||
Info.Log("g", "[test completed]");
|
Info.Log("g", "[test completed]");
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ public static class TestDtsodV23
|
|||||||
{
|
{
|
||||||
Info.Log("b", "[TestDtsodV23/TestSpeed]");
|
Info.Log("b", "[TestDtsodV23/TestSpeed]");
|
||||||
IDtsod dtsod=null;
|
IDtsod dtsod=null;
|
||||||
string text = File.ReadAllText("DtsodV2X\\messages.dtsod");
|
string text = File.ReadAllText($"DtsodV2X{Path.Sep}messages.dtsod");
|
||||||
Tester.LogOperationTime("V21 deserialization",100,()=>dtsod=new DtsodV21(text));
|
Tester.LogOperationTime("V21 deserialization",100,()=>dtsod=new DtsodV21(text));
|
||||||
Tester.LogOperationTime("V21 serialization", 100, () => _=dtsod.ToString());
|
Tester.LogOperationTime("V21 serialization", 100, () => _=dtsod.ToString());
|
||||||
Tester.LogOperationTime("V23 deserialization", 100, () => dtsod = new DtsodV23(text));
|
Tester.LogOperationTime("V23 deserialization", 100, () => dtsod = new DtsodV23(text));
|
||||||
@ -76,7 +76,7 @@ public static class TestDtsodV23
|
|||||||
public static void TestMemoryConsumption()
|
public static void TestMemoryConsumption()
|
||||||
{
|
{
|
||||||
Info.Log("b", "[TestDtsodV23/TestMemoryConsumption]");
|
Info.Log("b", "[TestDtsodV23/TestMemoryConsumption]");
|
||||||
string text = File.ReadAllText("DtsodV2X\\messages.dtsod");
|
string text = File.ReadAllText($"DtsodV2X{Path.Sep}messages.dtsod");
|
||||||
var a = GC.GetTotalMemory(true);
|
var a = GC.GetTotalMemory(true);
|
||||||
DtsodV23[] dtsods = new DtsodV23[100];
|
DtsodV23[] dtsods = new DtsodV23[100];
|
||||||
for (int i = 0; i < dtsods.Length; i++)
|
for (int i = 0; i < dtsods.Length; i++)
|
||||||
|
|||||||
@ -27,6 +27,7 @@ static class Program
|
|||||||
Console.Title="tester";
|
Console.Title="tester";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Info.Log("g","-------[DTLib tester]-------");
|
||||||
TestDtsodV23.TestAll();
|
TestDtsodV23.TestAll();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
@ -14,10 +14,10 @@
|
|||||||
<ProjectReference Include="..\DTLib\DTLib.csproj" />
|
<ProjectReference Include="..\DTLib\DTLib.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Update="DtsodV2X\*">
|
<None Include="DtsodV2X\*">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="DtsodV30\*">
|
<None Include="DtsodV30\*">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user