On 19.12.22 10:26, Tobias Burnus wrote: > And here is a more light-wight variant, suggested by Nightstrike: > > Using '.' instead of creating a new directory - and checking for > __WIN32__ instead for __MINGW32__. > > The only downside of this variant is that it does not check whether > "close(10,status='delete')" will delete a directory without failing with > an error. – If the latter makes sense, I think a follow-up check should > be added to ensure the directory has indeed been removed by 'close'. I have now updated the heavy version. The #if check moved to C as those macros aren't set in Fortran. (That's now https://gcc.gnu.org/PR108175 - I thought that there was a PR before, but I couldn't find any.) Additionally, on Windows the '.' directory is now opened - avoiding issues with POSIX functions (and the requirement to use '#include ' etc.). - As OPEN already fails, there is no point in checking for the rest. On the non-Windows side, there is now a check that 'CLOSE' with status='delete' indeed has deleted the directory. > Thoughts about which variant is better? Other suggestions or comments? ^- comments? > PS: On my x86-64 Linux, OPEN works but READ fails with EISDIR/errno == 21. And thanks to Nightstrike for testing, suggestions and reporting the issue at the first place. > On 19.12.22 10:09, Tobias Burnus wrote: >> As discussed in #gfortran IRC, on Windows opening a directory fails >> with EACCESS. >> (It works under Cygwin - nightstrike was so kind to test this.) >> >> Additionally, '[ -d dir ] || mkdir dir' is also not very portable. >> >> Hence, I use an auxiliary C file calling the POSIX functions and >> expect a fail for non-Cygwin windows. >> >> Comments? Suggestions? - If there aren't any, I plan to commit it >> as obvious tomorrow. I don't have a strong preference for the one-file/'.'/smaller solutions vs the two-file/mkdir/close-'delete' solution, but I am slightly inclined to the the one that tests more. Tobias ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955