diff --git a/DTLib.Logging/Loggers/FileLogger.cs b/DTLib.Logging/Loggers/FileLogger.cs index 0736c21..dc8f1d6 100644 --- a/DTLib.Logging/Loggers/FileLogger.cs +++ b/DTLib.Logging/Loggers/FileLogger.cs @@ -27,7 +27,7 @@ public class FileLogger : ILogger {} public FileLogger(string dir, string programName, ILogFormat format) - : this($"{dir}{Путь.Разд}{programName}_{DateTime.Now.ToString(MyTimeFormat.ForFileNames)}.log", format) + : this($"{dir}{Path.Sep}{programName}_{DateTime.Now.ToString(MyTimeFormat.ForFileNames)}.log", format) {} public FileLogger(string dir, string programName) : this(dir, programName, new DefaultLogFormat()) diff --git a/DTLib.Network/FSP.cs b/DTLib.Network/FSP.cs index d418497..b424b00 100644 --- a/DTLib.Network/FSP.cs +++ b/DTLib.Network/FSP.cs @@ -18,8 +18,8 @@ public class FSP // скачивает файл с помощью FSP протокола public void DownloadFile(string filePath_server, string filePath_client) { - Путь.Предупредить(filePath_server); - Путь.Предупредить(filePath_client); + Path.ThrowIfEscapes(filePath_server); + Path.ThrowIfEscapes(filePath_client); lock (MainSocket) { Debug("b", $"requesting file download: {filePath_server}"); @@ -31,7 +31,7 @@ public class FSP public void DownloadFile(string filePath_client) { - Путь.Предупредить(filePath_client); + Path.ThrowIfEscapes(filePath_client); using System.IO.Stream fileStream = File.OpenWrite(filePath_client); Download_SharedCode(fileStream, true); fileStream.Close(); @@ -40,7 +40,7 @@ public class FSP public byte[] DownloadFileToMemory(string filePath_server) { - Путь.Предупредить(filePath_server); + Path.ThrowIfEscapes(filePath_server); lock (MainSocket) { Debug("b", $"requesting file download: {filePath_server}"); @@ -102,7 +102,7 @@ public class FSP // отдаёт файл с помощью FSP протокола public void UploadFile(string filePath) { - Путь.Предупредить(filePath); + Path.ThrowIfEscapes(filePath); BytesUploaded = 0; Debug("b", $"uploading file {filePath}"); using System.IO.FileStream fileStream = File.OpenRead(filePath); @@ -137,10 +137,10 @@ public class FSP public void DownloadByManifest(string dirOnServer, string dirOnClient, bool overwrite = false, bool delete_excess = false) { - if (!dirOnClient.EndsWith(Путь.Разд)) - dirOnClient += Путь.Разд; - if (!dirOnServer.EndsWith(Путь.Разд)) - dirOnServer += Путь.Разд; + if (!dirOnClient.EndsWith(Path.Sep)) + dirOnClient += Path.Sep; + if (!dirOnServer.EndsWith(Path.Sep)) + dirOnServer += Path.Sep; Debug("b", "downloading manifest <", "c", dirOnServer + "manifest.dtsod", "b", ">"); var manifest = new DtsodV23(DownloadFileToMemory(dirOnServer + "manifest.dtsod").BytesToString(StringConverter.UTF8)); Debug("g", $"found {manifest.Values.Count} files in manifest"); @@ -183,8 +183,8 @@ public class FSP Log("y", $"can't create manifest, dir <{dir}> doesn't exist"); return; } - if (!dir.EndsWith(Путь.Разд)) - dir += Путь.Разд; + if (!dir.EndsWith(Path.Sep)) + dir += Path.Sep; Log($"b", $"creating manifest of {dir}"); StringBuilder manifestBuilder = new(); Hasher hasher = new(); diff --git a/DTLib.Tests/Dtsod/TestDtsodV23.cs b/DTLib.Tests/Dtsod/TestDtsodV23.cs index 5f7ac9a..82c5a33 100644 --- a/DTLib.Tests/Dtsod/TestDtsodV23.cs +++ b/DTLib.Tests/Dtsod/TestDtsodV23.cs @@ -17,7 +17,7 @@ public static class TestDtsodV23 public static void TestBaseTypes() { OldLogger.Log("c", "-----[TestDtsodV23/TestBaseTypes]-----"); - DtsodV23 dtsod = new(File.ReadAllText($"Dtsod{Путь.Разд}TestResources{Путь.Разд}DtsodV23{Путь.Разд}base_types.dtsod")); + DtsodV23 dtsod = new(File.ReadAllText($"Dtsod{Path.Sep}TestResources{Path.Sep}DtsodV23{Path.Sep}base_types.dtsod")); foreach (var pair in dtsod) OldLogger.Log("b", pair.Value.GetType().Name + ' ', "w", pair.Key + ' ', "c", pair.Value.ToString()); OldLogger.Log("g", "test completed"); @@ -25,7 +25,7 @@ public static class TestDtsodV23 public static void TestLists() { OldLogger.Log("c", "-------[TestDtsodV23/TestLists]-------"); - DtsodV23 dtsod = new(File.ReadAllText($"Dtsod{Путь.Разд}TestResources{Путь.Разд}DtsodV23{Путь.Разд}lists.dtsod")); + DtsodV23 dtsod = new(File.ReadAllText($"Dtsod{Path.Sep}TestResources{Path.Sep}DtsodV23{Path.Sep}lists.dtsod")); foreach (var pair in dtsod) { OldLogger.Log("b", pair.Value.GetType().Name + ' ', "w", pair.Key, "c", @@ -39,7 +39,7 @@ public static class TestDtsodV23 public static void TestComplexes() { OldLogger.Log("c", "-----[TestDtsodV23/TestComplexes]-----"); - DtsodV23 dtsod = new(File.ReadAllText($"Dtsod{Путь.Разд}TestResources{Путь.Разд}DtsodV23{Путь.Разд}complexes.dtsod")); + DtsodV23 dtsod = new(File.ReadAllText($"Dtsod{Path.Sep}TestResources{Path.Sep}DtsodV23{Path.Sep}complexes.dtsod")); foreach (var complex in dtsod) { OldLogger.Log("b", complex.Value.GetType().Name + ' ', "w", complex.Key, @@ -55,7 +55,7 @@ public static class TestDtsodV23 { OldLogger.Log("c", "--[TestDtsodV23/TestReSerialization]--"); var dtsod = new DtsodV23(new DtsodV23(new DtsodV23( - new DtsodV23(File.ReadAllText($"Dtsod{Путь.Разд}TestResources{Путь.Разд}DtsodV23{Путь.Разд}complexes.dtsod")).ToString()).ToString()).ToString()); + new DtsodV23(File.ReadAllText($"Dtsod{Path.Sep}TestResources{Path.Sep}DtsodV23{Path.Sep}complexes.dtsod")).ToString()).ToString()).ToString()); OldLogger.Log("y", dtsod.ToString()); OldLogger.Log("g", "test completed"); } @@ -64,7 +64,7 @@ public static class TestDtsodV23 { OldLogger.Log("c", "-------[TestDtsodV23/TestSpeed]-------"); IDtsod dtsod=null; - string text = File.ReadAllText($"Dtsod{Путь.Разд}TestResources{Путь.Разд}DtsodV23{Путь.Разд}messages.dtsod"); + string text = File.ReadAllText($"Dtsod{Path.Sep}TestResources{Path.Sep}DtsodV23{Path.Sep}messages.dtsod"); LogOperationTime("V21 deserialization",64,()=>dtsod=new DtsodV21(text)); LogOperationTime("V21 serialization", 64, () => _=dtsod.ToString()); LogOperationTime("V23 deserialization", 64, () => dtsod = new DtsodV23(text)); @@ -75,7 +75,7 @@ public static class TestDtsodV23 public static void TestMemoryConsumption() { OldLogger.Log("c", "----[TestDtsodV23/TestMemConsumpt]----"); - string text = File.ReadAllText($"Dtsod{Путь.Разд}TestResources{Путь.Разд}DtsodV23{Путь.Разд}messages.dtsod"); + string text = File.ReadAllText($"Dtsod{Path.Sep}TestResources{Path.Sep}DtsodV23{Path.Sep}messages.dtsod"); var a = GC.GetTotalMemory(true); var dtsods = new DtsodV23[64]; for (int i = 0; i < dtsods.Length; i++) diff --git a/DTLib.Tests/Dtsod/TestDtsodV24.cs b/DTLib.Tests/Dtsod/TestDtsodV24.cs index 5e840bb..3861c36 100644 --- a/DTLib.Tests/Dtsod/TestDtsodV24.cs +++ b/DTLib.Tests/Dtsod/TestDtsodV24.cs @@ -18,7 +18,7 @@ public static class TestDtsodV24 public static void TestBaseTypes() { OldLogger.Log("c", "-----[TestDtsodV24/TestBaseTypes]-----"); - DtsodV24 dtsod = new(File.ReadAllText($"Dtsod{Путь.Разд}TestResources{Путь.Разд}DtsodV24{Путь.Разд}base_types.dtsod")); + DtsodV24 dtsod = new(File.ReadAllText($"Dtsod{Path.Sep}TestResources{Path.Sep}DtsodV24{Path.Sep}base_types.dtsod")); foreach (var pair in dtsod) OldLogger.Log("b", pair.ToString()); OldLogger.Log("g", "test completed"); @@ -27,7 +27,7 @@ public static class TestDtsodV24 public static void TestComplexes() { OldLogger.Log("c", "-----[TestDtsodV24/TestComplexes]-----"); - DtsodV24 dtsod = new(File.ReadAllText($"Dtsod{Путь.Разд}TestResources{Путь.Разд}DtsodV24{Путь.Разд}complexes.dtsod")); + DtsodV24 dtsod = new(File.ReadAllText($"Dtsod{Path.Sep}TestResources{Path.Sep}DtsodV24{Path.Sep}complexes.dtsod")); OldLogger.Log("h", dtsod.ToString()); OldLogger.Log("g", "test completed"); } @@ -35,7 +35,7 @@ public static class TestDtsodV24 public static void TestLists() { OldLogger.Log("c", "-------[TestDtsodV24/TestLists]-------"); - DtsodV24 dtsod = new(File.ReadAllText($"Dtsod{Путь.Разд}TestResources{Путь.Разд}DtsodV24{Путь.Разд}lists.dtsod")); + DtsodV24 dtsod = new(File.ReadAllText($"Dtsod{Path.Sep}TestResources{Path.Sep}DtsodV24{Path.Sep}lists.dtsod")); foreach (KVPair pair in dtsod) { var list = new Autoarr(pair.value.VoidPtr, false); @@ -60,7 +60,7 @@ public static class TestDtsodV24 { OldLogger.Log("c", "--[TestDtsodV24/TestReSerialization]--"); var dtsod = new DtsodV24(new DtsodV24(new DtsodV24( - new DtsodV24(File.ReadAllText($"Dtsod{Путь.Разд}TestResources{Путь.Разд}DtsodV24{Путь.Разд}complexes.dtsod")).ToString()).ToString()).ToString()); + new DtsodV24(File.ReadAllText($"Dtsod{Path.Sep}TestResources{Path.Sep}DtsodV24{Path.Sep}complexes.dtsod")).ToString()).ToString()).ToString()); OldLogger.Log("h", dtsod.ToString()); OldLogger.Log("g", "test completed"); } @@ -69,12 +69,12 @@ public static class TestDtsodV24 { OldLogger.Log("c", "-------[TestDtsodV24/TestSpeed]-------"); IDtsod dtsod=null; - string _text = File.ReadAllText($"Dtsod{Путь.Разд}TestResources{Путь.Разд}DtsodV23{Путь.Разд}messages.dtsod"); + string _text = File.ReadAllText($"Dtsod{Path.Sep}TestResources{Path.Sep}DtsodV23{Path.Sep}messages.dtsod"); string text = ""; LogOperationTime( "V23 to V24 conversion", 32, ()=> text = DtsodConverter.ConvertVersion(new DtsodV23(_text), DtsodVersion.V24).ToString() ); - File.WriteAllText($"Dtsod{Путь.Разд}TestResources{Путь.Разд}DtsodV24{Путь.Разд}messages.dtsod",text); + File.WriteAllText($"Dtsod{Path.Sep}TestResources{Path.Sep}DtsodV24{Path.Sep}messages.dtsod",text); LogOperationTime("V24 deserialization", 64, () => dtsod = new DtsodV24(text)); LogOperationTime("V24 serialization", 64, () => text = dtsod.ToString()); OldLogger.Log("g", "test completed"); diff --git a/DTLib/DependencyResolver.cs b/DTLib/DependencyResolver.cs index fc43bb2..b9f5f63 100644 --- a/DTLib/DependencyResolver.cs +++ b/DTLib/DependencyResolver.cs @@ -9,14 +9,14 @@ public static class DependencyResolver public static void CopyLibs() { if(DepsCopied) return; - string depsdir = $"Dependencies{Путь.Разд}"; + string depsdir = $"Dependencies{Path.Sep}"; depsdir += Environment.OSVersion.Platform switch { PlatformID.Unix => "linux", PlatformID.Win32NT => "windows", _=> throw new Exception($"unsupported os {Environment.OSVersion.Platform}") }; - depsdir += Путь.Разд; + depsdir += Path.Sep; depsdir += RuntimeInformation.ProcessArchitecture switch { Architecture.X64 => "x64", @@ -27,7 +27,7 @@ public static class DependencyResolver }; foreach (var file in Directory.GetAllFiles(depsdir)) { - var extracted = file.Substring(file.LastIndexOf(Путь.Разд) + 1); + var extracted = file.Substring(file.LastIndexOf(Path.Sep) + 1); File.Copy(file,extracted, true); Log("g",$"{extracted} copied"); } diff --git a/DTLib/Experimental/FileInstance.cs b/DTLib/Experimental/FileInstance.cs new file mode 100644 index 0000000..a457fbd --- /dev/null +++ b/DTLib/Experimental/FileInstance.cs @@ -0,0 +1,45 @@ +using System.IO; + +namespace DTLib.Experimental; + +public class FileInstance +{ + public enum FileOpenMode + { + // open a file for reading + Read=1, + // (re)create a file for writing + Write=2, + // opens file for writing additional data to the end / creates new file + Append=4, + // (re)creates file for reading/writing + ReadWrite=Read|Write, + // opens file for readng/writing additional data to the end / creates new file + ReadAppend=Read|Append + } + + public readonly FileOpenMode Mode; + public readonly FileStream Stream; + public string Name; + + public FileInstance(string path, FileOpenMode mode) + { + if (path.IsNullOrEmpty()) + throw new NullReferenceException("path is null"); + if(!System.IO.File.Exists(path)) + { + if (mode == FileOpenMode.Read) + throw new Exception($"file <{path}> is not found"); + } + Mode = mode; + Stream = mode switch + { + FileOpenMode.Read => System.IO.File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), + FileOpenMode.Write => System.IO.File.Open(path, FileMode.Open, FileAccess.Write, FileShare.ReadWrite), + FileOpenMode.Append => System.IO.File.Open(path, FileMode.Append, FileAccess.Write, FileShare.ReadWrite), + FileOpenMode.ReadWrite => System.IO.File.Open(path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite), + FileOpenMode.ReadAppend => System.IO.File.Open(path, FileMode.Append, FileAccess.ReadWrite, FileShare.ReadWrite), + _ => throw new Exception($"unknown file mode: {mode}") + }; + } +} \ No newline at end of file diff --git a/DTLib/Extensions/StringConverter.cs b/DTLib/Extensions/StringConverter.cs index 6dc3032..40f5db0 100644 --- a/DTLib/Extensions/StringConverter.cs +++ b/DTLib/Extensions/StringConverter.cs @@ -43,35 +43,51 @@ public static class StringConverter public static bool StartsWith(this string s, char c) => s[0] == c; public static bool EndsWith(this string s, char c) => s[s.Length - 1] == c; - public static string MergeToString(params object[] parts) + // String.Join(sep,string...) does some low-level memory manipulations, that are faster than StringBuilder + public static string MergeToString(params string[] parts) + =>string.Join(null, parts); + + public static string MergeToString(params TVal[] parts) { + if (parts.Length == 0) + return ""; StringBuilder builder = new(); for (int i = 0; i < parts.Length; i++) builder.Append(parts[i]); return builder.ToString(); } - - // String.Join(sep,string...) does some low-level memory manipulations, that are faster than StringBuilder - public static string MergeToString(params string[] parts) - =>string.Join(null, parts); - - public static string MergeToString(this IEnumerable collection, string separator) + public static string MergeToString(TSep separator, params TVal[] parts) { - StringBuilder builder = new(); - foreach (T elem in collection) - { - builder.Append(elem); - builder.Append(separator); - } - if (builder.Length == 0) + if (parts.Length == 0) return ""; - builder.Remove(builder.Length - separator.Length, separator.Length); + StringBuilder builder = new(); + builder.Append(parts[0]); + for (int i = 1; i < parts.Length; i++) + { + builder.Append(separator); + builder.Append(parts[i]); + } return builder.ToString(); } - public static string MergeToString(this IEnumerable collection) + + public static string MergeToString(this IEnumerable collection, TSep separator) { StringBuilder builder = new(); - foreach (T elem in collection) + using var e = collection.GetEnumerator(); + if(e.MoveNext()) + builder.Append(e.Current); + while (e.MoveNext()) + { + builder.Append(separator); + builder.Append(e.Current); + } + return builder.ToString(); + } + + public static string MergeToString(this IEnumerable collection) + { + StringBuilder builder = new(); + foreach (var elem in collection) builder.Append(elem); return builder.ToString(); } diff --git a/DTLib/Filesystem/Directory.cs b/DTLib/Filesystem/Directory.cs index 8ed3de6..bf7158a 100644 --- a/DTLib/Filesystem/Directory.cs +++ b/DTLib/Filesystem/Directory.cs @@ -10,8 +10,8 @@ public static class Directory if (!Exists(dir)) { // проверяет существование папки, в которой нужно создать dir - if (dir.Contains(Путь.Разд) && !Exists(dir.Remove(dir.LastIndexOf(Путь.Разд)))) - Create(dir.Remove(dir.LastIndexOf(Путь.Разд))); + if (dir.Contains(Path.Sep) && !Exists(dir.Remove(dir.LastIndexOf(Path.Sep)))) + Create(dir.Remove(dir.LastIndexOf(Path.Sep))); System.IO.Directory.CreateDirectory(dir); } } @@ -100,8 +100,8 @@ public static class Directory public static void CreateSymlink(string sourceName, string symlinkName) { - if (symlinkName.Contains(Путь.Разд)) - Create(symlinkName.Remove(symlinkName.LastIndexOf(Путь.Разд))); + if (symlinkName.Contains(Path.Sep)) + Create(symlinkName.Remove(symlinkName.LastIndexOf(Path.Sep))); if (!Symlink.CreateSymbolicLink(symlinkName, sourceName, Symlink.SymlinkTarget.Directory)) 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) { List files = GetAllFiles(srcdir); - if (!srcdir.EndsWith(Путь.Разд)) srcdir += Путь.Разд; - if (!newdir.EndsWith(Путь.Разд)) newdir += Путь.Разд; + if (!srcdir.EndsWith(Path.Sep)) srcdir += Path.Sep; + if (!newdir.EndsWith(Path.Sep)) newdir += Path.Sep; int i = 0; for (; i < files.Count; i++) File.CreateSymlink(files[i], files[i].Replace(srcdir, newdir)); diff --git a/DTLib/Filesystem/File.cs b/DTLib/Filesystem/File.cs index 756b5da..1be3f16 100644 --- a/DTLib/Filesystem/File.cs +++ b/DTLib/Filesystem/File.cs @@ -3,7 +3,7 @@ namespace DTLib.Filesystem; public static class File { - public static int GetSize(string file) => new System.IO.FileInfo(file).Length.ToInt(); + public static long GetSize(string file) => new System.IO.FileInfo(file).Length; public static bool Exists(string file) => System.IO.File.Exists(file); @@ -12,8 +12,8 @@ public static class File { if (!Exists(file)) { - if (file.Contains(Путь.Разд)) - Directory.Create(file.Remove(file.LastIndexOf(Путь.Разд))); + if (file.Contains(Path.Sep)) + Directory.Create(file.Remove(file.LastIndexOf(Path.Sep))); using System.IO.FileStream stream = System.IO.File.Create(file); stream.Close(); } @@ -32,9 +32,10 @@ public static class File public static byte[] ReadAllBytes(string file) { using System.IO.FileStream stream = OpenRead(file); - int size = GetSize(file); + int size = GetSize(file).ToInt(); byte[] output = new byte[size]; - stream.Read(output, 0, size); + if (stream.Read(output, 0, size) < size) + throw new Exception("can't read all bytes"); stream.Close(); return output; } @@ -78,8 +79,8 @@ public static class File public static void CreateSymlink(string sourceName, string symlinkName) { - if (symlinkName.Contains(Путь.Разд)) - Directory.Create(symlinkName.Remove(symlinkName.LastIndexOf(Путь.Разд))); + if (symlinkName.Contains(Path.Sep)) + Directory.Create(symlinkName.Remove(symlinkName.LastIndexOf(Path.Sep))); if (!Symlink.CreateSymbolicLink(symlinkName, sourceName, Symlink.SymlinkTarget.File)) throw new InvalidOperationException($"some error occured while creating symlink\nFile.CreateSymlink({symlinkName}, {sourceName})"); } diff --git a/DTLib/Filesystem/Path.cs b/DTLib/Filesystem/Path.cs new file mode 100644 index 0000000..864fd4e --- /dev/null +++ b/DTLib/Filesystem/Path.cs @@ -0,0 +1,74 @@ +using System.Runtime.CompilerServices; + +namespace DTLib.Filesystem; + +public static class Path +{ + + public static readonly char Sep = Environment.OSVersion.Platform == PlatformID.Win32NT ? '\\' : '/'; + private static readonly char NotSep = Environment.OSVersion.Platform == PlatformID.Win32NT ? '/' : '\\' ; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static string Concat(string path, string addition) => $"{path}{Sep}{addition}"; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static string Concat(params string[] parts) => StringConverter.MergeToString(Sep, parts); + + public static string FixSeparators(string path) + { + var chars = path.ToCharArray(); + int length = path.Length; + for(int i=0; i FixSeparators(Concat(parts)); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static string Resolve(string path, string addition) => FixSeparators(Concat(path, addition)); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void ThrowIfEscapes(string path) + { + if (path.Contains("..")) + throw new Exception($"path <{path}> uses <..>, that's not allowed"); + } + + /// Replaces restricted characters in string + public static string CorrectString(string str) + { +#if NETSTANDARD2_1 || NET6_0 || NET7_0 || NET8_0 + var a = str.AsSpan(); +#else + var a = str.ToArray(); +#endif + char[] r = new char[a.Length]; + for (int i = 0; i < a.Length; i++) + { + switch (a[i]) + { + case '/': case '\\': + case ':': case ';': + r[i] = '-'; + break; + case '\n': case '\r': case ' ': + case '#': case '%': case '&': + case '{': case '}': case '<': + case '>': case '*': case '?': + case '$': case '!': case '\'': + case '"': case '@': case '+': + case '`': case '|': case '=': + r[i] = '_'; + break; + default: + r[i] = a[i]; + break; + } + } + + return new string(r); + } +} \ No newline at end of file diff --git a/DTLib/Filesystem/Путь.cs b/DTLib/Filesystem/Путь.cs deleted file mode 100644 index 7e8baf1..0000000 --- a/DTLib/Filesystem/Путь.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace DTLib.Filesystem; - -public static class Путь -{ - public static readonly char Разд = Environment.OSVersion.Platform == PlatformID.Win32NT ? '\\' : '/'; - - public static string ИсправитьРазд(this string путь) - { - if (Разд == '\\') - { - if (путь.Contains('/')) - путь = путь.Replace('/', '\\'); - } - else - { - if (путь.Contains('\\')) - путь = путь.Replace('\\', '/'); - } - return путь; - } - - // replaces wrong characters to use string as путь - public static string НормализоватьДляПути(this string путь) => - путь.Replace(':', '-').Replace(' ', '_'); - - public static void Предупредить(string может_быть_с_точками) - { - if(может_быть_с_точками.Contains("..")) - throw new Exception($"лее точки двойные убери: {может_быть_с_точками}"); - } -} \ No newline at end of file diff --git a/DTLib/Logging/FileLogger.cs b/DTLib/Logging/FileLogger.cs index eb674aa..b0c5ade 100644 --- a/DTLib/Logging/FileLogger.cs +++ b/DTLib/Logging/FileLogger.cs @@ -9,7 +9,7 @@ public class FileLogger : IDisposable } public FileLogger(string dir, string programName) - : this($"{dir}{Путь.Разд}{programName}_{DateTime.Now.ToString(MyTimeFormat.ForFileNames)}.log") { } + : this($"{dir}{Path.Sep}{programName}_{DateTime.Now.ToString(MyTimeFormat.ForFileNames)}.log") { } public string LogfileName { get; protected set; } public System.IO.FileStream LogfileStream { get; protected set; }