Files
Nim/lib/pure
havardjohn 68f92af17c Fix cannot create Windows directory in root (#20311)
* Fix cannot create Windows directory in root

Fixes #20306, a regression bug with `createDir` caused by
`23e0160af283bb0bb573a86145e6c1c792780d49`.

The issue is that, if the path consists only of a drive and a single
directory (e.g. "Y:\nimcache2" in the original issue), then no
directories will be created. This works fine if there are multiple
directories (e.g. "Y:\nimcache2\test").

In the case of "Y:\nimcache2", `omitNext` in `createDir` is `false` on
the last condition in `createDir`. This means that the "nimcache2"
directory will not be created, and no exception will be raised.

Fixed by refactoring to use `parentDirs` iterator instead of iterating
over the string characters. Motivation is reduced code complexity.

Will not test the specific "C:\test" `createDir` case, since there is no
standard Windows drive with write permissions in the root. Creating a
custom drive-mapping to Windows Temp is a non-option. That could mess
up some users running the test.

Added `parentDirs` tests since they are lacking on for POSIX paths.

* Fix `createDir("")` causing error

The change to `createDir` caused `createDir("")` to raise an error,
where it previously didn't. Fixed so `createDir("")` does not fail, and
added test case.
2022-09-11 16:51:39 -04:00
..
2021-08-31 08:14:05 +02:00
2021-12-20 10:40:32 +01:00
2022-06-04 07:03:03 +02:00
2015-10-01 12:05:45 -07:00
2021-02-23 21:05:39 -08:00
2021-07-13 09:22:33 +02:00
2021-04-08 14:08:58 +02:00
2022-02-02 17:10:11 +01:00
2021-01-09 00:24:41 +01:00
2022-02-14 22:15:59 +00:00
2021-04-06 22:08:59 +02:00
2021-02-24 21:47:27 -08:00
2022-02-02 17:10:11 +01:00
2022-02-02 17:10:11 +01:00
2022-02-02 17:10:11 +01:00
2021-08-23 00:13:39 +02:00
2022-09-11 13:50:06 -04:00
2021-10-05 12:29:59 +02:00
2021-09-19 23:35:50 +02:00
2021-02-08 09:46:07 +01:00
2022-02-02 17:10:11 +01:00