dirkwhoffmann / virtualc64

VirtualC64 is a cycle-accurate C64 emulator for macOS
https://dirkwhoffmann.github.io/virtualc64
Other
351 stars 33 forks source link

Exporting d64 to directory fails on certain filenames #712

Closed Schlumpfpapa closed 2 years ago

Schlumpfpapa commented 2 years ago

Trying to export a disk to a directory aborts on the first file which C64 name contains a "/".

dirkwhoffmann commented 2 years ago

Thanks for reporting! Seems like I need to replace certain symbols before creating the files on the host OS.

dirkwhoffmann commented 2 years ago

Will be fixed in the next release.

Test case: TestDisk.d64.zip

Bildschirmfoto 2022-04-29 um 18 21 59

After exporting:

> ls ~/tmp/exports 
MY%2fTEST

A new function called fileSystemRepresentation has been added to class FSDirEntry to compute the file name for the host OS:

string
FSDirEntry::getFileSystemRepresentation() const
{
    auto name = getName().str();
    string illegal = "#%&{}\\<>*?/ $!'\":@+`|=";
    string result;

    for (const auto c: name) {

        if (illegal.find(c) != std::string::npos) {
            result += "%" + util::hexstr<2>(c);
        } else {
            result += c;
        }
    }
    return result;
}
dirkwhoffmann commented 2 years ago

v4.5b1 is online.