ReplaceRestrictedChars
This commit is contained in:
parent
48eab00a37
commit
b86e565077
@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<!--package info-->
|
||||
<PackageId>DTLib.Dtsod</PackageId>
|
||||
<Version>1.1.4</Version>
|
||||
<Version>1.1.5</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.1.5" />
|
||||
<PackageReference Include="DTLib" Version="1.1.9" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--project files-->
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<!--package info-->
|
||||
<PackageId>DTLib.Logging</PackageId>
|
||||
<Version>1.1.4</Version>
|
||||
<Version>1.1.5</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.1.5" />
|
||||
<PackageReference Include="DTLib" Version="1.1.9" />
|
||||
<PackageReference Include="DTLib.Ben.Demystifier" Version="1.0.4" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<!--package info-->
|
||||
<PackageId>DTLib.Network</PackageId>
|
||||
<Version>1.1.4</Version>
|
||||
<Version>1.1.5</Version>
|
||||
<Authors>Timerix</Authors>
|
||||
<Description>Some sick network protocols</Description>
|
||||
<RepositoryType>GIT</RepositoryType>
|
||||
@ -32,6 +32,6 @@
|
||||
<ProjectReference Include="..\DTLib.Dtsod\DTLib.Dtsod.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
|
||||
<PackageReference Include="DTLib.Dtsod" Version="1.1.4" />
|
||||
<PackageReference Include="DTLib.Dtsod" Version="1.1.5" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@ -27,10 +27,10 @@
|
||||
<ProjectReference Include="..\DTLib\DTLib.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
|
||||
<PackageReference Include="DTLib" Version="1.1.5" />
|
||||
<PackageReference Include="DTLib.Dtsod" Version="1.1.4" />
|
||||
<PackageReference Include="DTLib.Network" Version="1.1.4" />
|
||||
<PackageReference Include="DTLib.Logging" Version="1.1.4" />
|
||||
<PackageReference Include="DTLib" Version="1.1.9" />
|
||||
<PackageReference Include="DTLib.Dtsod" Version="1.1.5" />
|
||||
<PackageReference Include="DTLib.Network" Version="1.1.5" />
|
||||
<PackageReference Include="DTLib.Logging" Version="1.1.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--project files-->
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<!--package info-->
|
||||
<PackageId>DTLib</PackageId>
|
||||
<Version>1.1.8</Version>
|
||||
<Version>1.1.9</Version>
|
||||
<Authors>Timerix</Authors>
|
||||
<Description>Library for all my C# projects</Description>
|
||||
<RepositoryType>GIT</RepositoryType>
|
||||
|
||||
@ -19,33 +19,38 @@ public static class Path
|
||||
throw new Exception($"path <{path}> uses <..>, that's not allowed");
|
||||
}
|
||||
|
||||
/// Replaces restricted characters in string
|
||||
/// Replaces characters restricted in filesystem path
|
||||
public static IOPath ReplaceRestrictedChars(string str)
|
||||
{
|
||||
char[] r = str.ToCharArray();
|
||||
|
||||
StringBuilder b = new(r.Length);
|
||||
for (int i = 0; i < str.Length; i++)
|
||||
{
|
||||
switch (r[i])
|
||||
char c = r[i];
|
||||
switch (c)
|
||||
{
|
||||
case '/': case '\\':
|
||||
case '\n': case '\r':
|
||||
case ':': case ';':
|
||||
r[i] = '-';
|
||||
break;
|
||||
case '\n': case '\r': case '\'':
|
||||
case '"': case '`':
|
||||
case '/': case '\\':
|
||||
b.Append('-');
|
||||
break;
|
||||
case ' ': case '&': case '{': case '}':
|
||||
case '<': case '>': case '*': case '?':
|
||||
case '$': case '%': case '@': case '|':
|
||||
// case '!':
|
||||
// case '#':
|
||||
r[i] = '_';
|
||||
case '<': case '>':
|
||||
case '?': case '|':
|
||||
b.Append('_');
|
||||
break;
|
||||
case '"':
|
||||
b.Append('\'');
|
||||
break;
|
||||
case '*':
|
||||
b.Append('X');
|
||||
break;
|
||||
default:
|
||||
b.Append(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return new IOPath(r);
|
||||
return new IOPath(b.ToString(), true);
|
||||
}
|
||||
|
||||
#if !USE_SPAN
|
||||
|
||||
Loading…
Reference in New Issue
Block a user