Add unlink(2) implementation for CP/M.
Hello --
When compiling C code for CP/M, unlink is accepted by the compiler via the unistd.h header but then fails when linking due to an undefined reference for _unlink.
This PR adds an unlink implementation for CP/M.
I am not 100% sure the errno = EIO is the correct errno for when cpm_delete_file returns 0xff, but this is good enough for my needs.
Thanks!
Thanks very much! I've left a couple of comments.
Hello --
Thanks. (However, I don't see any comments anywhere...)
That is, github review comments, not code comments! They should show up in the github UI here, above this message: https://github.com/davidgiven/ack/pull/235
Embarrassingly, my GitHub UI appears to be broken (though I am using Chrome on Windows atm): there is no github review anywhere for me...
Hello @ibara, hello @davidgiven,
I do not see any GitHub review comments either (?). Meanwhile I have a few queries of my own on this PR:
- Is it really necessary to find an empty slot in the
__fd[]array? I would think that the FCB could simply be created on the stack, andunlinkcan do the file deletion from there. - If the code is going to touch the
__fd[]array, then should it use__fd[]to check that the file to beunlink-ed is not currently open? Is it OK under CP/M to remove a file that is still open?
(My knowledge of the CP/M interface is admittedly quite limited — but I had been looking at Microsoft's GW-BASIC implementation of the KILL command for deleting files, which uses CP/M-like FCBs under MS-DOS 1.x.)
Thank you!
My knowledge of the CP/M interface is also limited. I freely and fully admit to stealing this code from another library file (maybe open?) and modifying it until it did the right thing for my use case. I am sure it needs lots of improvement!
Very very belatedly someone told me that github doesn't actually send reviews until you do something unobvious. Hopefully I've done that now. Sorry for the delay.