cannot remove directories in fsdevice
Versatile Commodore Emulator
Brought to you by:
blackystardust,
gpz
Appearance: The DOS command @RD is used to remove (empty) directories. In the vice virtual filesystem (fsdevice), this command always fails. The error message is 80, directory not empty, even when the directory is empty.
Probable cause: Internally, this command is handled by fsdevice_flush_remove, which calls ioutil_remove, which in turn calls unlink(2). But unlink fails because it cannot remove directories. Then, fsdevice_flush_remove assumes that 80 is the correct error code to report, regardless of the actual error from the operating system.
Suggested fix: Call rmdir(2) instead of unlink(2), when handling the RD command.
Fixed in r34733. Please give it a try.
For now I've only tested this in Linux. The fsdevice_flush_rmdir() uses a hardcoded '/' to construct the path to the directory to remove, which should work in Unix, BeOS and Windows, not sure about MSDOS or AmigaOS. So a function like archdep_join_paths() might be required.
I've noticed there are more problems in fsdevice_flush.c: some functions, including fsdevice_flush_remove(), assume the cwd is the same as a drive's virtual FS directory, but this isn't always the case (the 'FSDevice[8-11]Dir' resources can be used to set a directory). So I suppose there are more bugs to fix.
Last edit: compyx 2018-05-01