MrHiggins wrote: ↑Fri 12 Aug 2022, 09:55
The platform agnostic solution to this I have gone for is before executing the MKDIR I will look to see if there is a directory there already and if there is skip it.
Have you actually tested that on any platform other than Windows? I thought the NUL pseudo-file was a Windows-specific feature and didn't work on any other platform, but I'm happy to be proved wrong.
It's perhaps also worth reminding everybody that this is a case when trying something and seeing if an error occurs is the
correct way to do it, because any other approach is prone to failure in a multi-tasking operating system. Although the chances are probably small, it's possible for this sequence of events to occur:
- The BBC BASIC program tests to see if the directory exists, it doesn't.
- Another program creates the directory (either through running on another core or because of a task-switch).
- The BBC BASIC program tries to create the directory, and fails with an error.
The only safe way is to test whether the directory exists and if not create it
as an atomic operation (one which cannot be interrupted by another task), which can only be achieved by trapping the error and attempting it anyway.
I know it's unreasonable to expect BBC BASIC programmers to test their code on every supported platform, but I would urge checking it on at least two dissimilar platforms (e.g. Windows and 64-bit Linux or Windows and MacOS). Even if you don't have a suitable alternative platform, you can usually test your code by running it in a browser, which will check most things except 64-bit compatibility.
For the record, these are the platforms on which I test every release of BBCSDL: Windows 10 32-bit (desktop), Windows 10 64-bit (desktop), Windows 10 64-bit (laptop with touchscreen), MacOS (x86 CPU), MacOS (M1 CPU), Ubuntu 18.04 32-bit, Ubuntu 18.04 64-bit, Raspberry Pi 4 32-bit, Raspberry Pi 4 64-bit, Android phone (x86), Android phone (ARM), Android tablet (ARM), iPod Touch, iPhone 5, iPad mini and in Chrome, Edge & Firefox!
When I am no longer able to do that (sadly probably quite soon) anybody contemplating taking over the role is going to need access to at least as many systems for testing.
