beyond-all-reason/pr-downloader

CFileSystem::getMBsFree "still" seems to fail when the path contains non-ASCII characters

rafidka opened this issue · 3 comments

I reported this issue back in April on spring's pr-downloader spring/pr-downloader#145 and it is supposed to have been fixed spring/pr-downloader#145 in there and ported to BAR's pr-downloader as well 34cf14a. However, a user reported the same issue today so it doesn't seem to have been actually fixed.

Thank you for opening it, I will try to reproduce the issue over the weekend and look at the fix.

Notes from my analysis so far:

Reproduced this on Windows with simple call but also with

spawnSync('C:/Users/Marek/pr-downloader.exe', ['--filesystem-writepath', 'ąćźż汉语'], {stdio: 'inherit'});

in node.js shell.

Overall the issue is that argv on windows is being flatten to the default codepage that isn't unicode.

To get access to the full argv, it's possible to use the wmain variant, or use CommandLineToArgvW to get argumnts in regular main. ffmpeg does something like this: https://github.com/FFmpeg/FFmpeg/blob/6195a0ee191728b4e638cf3b620e68acde8854b0/fftools/cmdutils.c#L209

There is also stuff like https://github.com/boostorg/nowide that also provides the other side: allows to use utf8 with fopen etc. pr-downloader already has FileSystem that handles that properly, that could be rewritten with C++17's std::filesystem.

Ok, I have a draft #23 ready, need to do a bit more testing.