mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-14 20:54:16 +01:00
Remove all non-ascii symbols from path during import, because FFXIV can not handle them correctly.
This commit is contained in:
parent
04c42b7842
commit
6012b2c6ea
2 changed files with 21 additions and 1 deletions
|
|
@ -190,7 +190,7 @@ namespace Penumbra.Importer
|
||||||
private DirectoryInfo CreateModFolder( string modListName )
|
private DirectoryInfo CreateModFolder( string modListName )
|
||||||
{
|
{
|
||||||
var correctedPath = Path.Combine( _outDirectory.FullName,
|
var correctedPath = Path.Combine( _outDirectory.FullName,
|
||||||
Path.GetFileName( modListName ).RemoveInvalidPathSymbols() );
|
Path.GetFileName( modListName ).RemoveInvalidPathSymbols().RemoveNonAsciiSymbols() );
|
||||||
var newModFolder = new DirectoryInfo( correctedPath );
|
var newModFolder = new DirectoryInfo( correctedPath );
|
||||||
var i = 2;
|
var i = 2;
|
||||||
while( newModFolder.Exists && i < 12 )
|
while( newModFolder.Exists && i < 12 )
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace Penumbra
|
namespace Penumbra
|
||||||
{
|
{
|
||||||
|
|
@ -11,5 +13,23 @@ namespace Penumbra
|
||||||
|
|
||||||
public static string RemoveInvalidPathSymbols( this string s )
|
public static string RemoveInvalidPathSymbols( this string s )
|
||||||
=> string.Concat( s.Split( _invalid ) );
|
=> string.Concat( s.Split( _invalid ) );
|
||||||
|
|
||||||
|
public static string RemoveNonAsciiSymbols( this string s, string replacement = "_" )
|
||||||
|
{
|
||||||
|
StringBuilder sb = new( s.Length );
|
||||||
|
foreach( var c in s )
|
||||||
|
{
|
||||||
|
if( c < 128 )
|
||||||
|
{
|
||||||
|
sb.Append( c );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sb.Append( replacement );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue