MaKiPL / OpenVIII-monogame

Open source Final Fantasy VIII engine implementation in C# working on Windows and Linux (Android and iOS planned too!) [Monogame]
MIT License
645 stars 59 forks source link

Calls to `Path.GetFileName*` are liable to fail on Linux #156

Open cmbasnett opened 4 years ago

cmbasnett commented 4 years ago

The C# function Path.GetFileName and Path.GetFileNameWithoutExtension work with native platform directory separators (\ on Windows, / on Linux). This creates problems on Linux, since the game's internal data uses Windows-style paths.

For example:

var path = "C:\\ff8\\Data\\eng\\FIELD\\model\\main_chr\\d000.mch"
var fileName = Path.GetFileNameWithoutExtension(path);
Console.WriteLine(fileName);

// Windows
>> "d000"

// Linux
>> "C:\\ff8\\Data\\eng\\FIELD\\model\\main_chr\\d000"

I will explore a solution on my fork and make a PR.

Let me know if you have any preference as to how to deal with this.

Sebanisu commented 4 years ago

https://source.dot.net/#System.Private.CoreLib/PathInternal.Unix.cs,cffe6f0bdd450298 seems to confirm what you're saying

Maki has a method to force path names to have correct slash. Maybe could use that to prep the data. It's in the extended.cs

Like where we read the strings in we could change all the slashes to correct ones.

Maybe we can overload utf8 encoding to swap the slashes as it's reading the strings.