Allow Penumbra to use long and arbitrary UTF8 paths.

This commit is contained in:
Ottermandias 2023-02-12 13:19:18 +01:00
parent 68a787d125
commit 08519396a0
7 changed files with 195 additions and 31 deletions

View file

@ -156,9 +156,7 @@ public partial class Mod
private static DirectoryInfo NewOptionDirectory( DirectoryInfo baseDir, string optionName )
=> new(Path.Combine( baseDir.FullName, ReplaceBadXivSymbols( optionName ) ));
// XIV can not deal with non-ascii symbols in a path,
// and the path must obviously be valid itself.
// Normalize for nicer names, and remove invalid symbols or invalid paths.
public static string ReplaceBadXivSymbols( string s, string replacement = "_" )
{
if( s == "." )
@ -174,7 +172,7 @@ public partial class Mod
StringBuilder sb = new(s.Length);
foreach( var c in s.Normalize( NormalizationForm.FormKC ) )
{
if( c.IsInvalidAscii() || c.IsInvalidInPath() )
if( c.IsInvalidInPath() )
{
sb.Append( replacement );
}