Stream: helpdesk (published)

Topic: isdir || mkdir


view this post on Zulip Dale Black (May 22 2021 at 18:53):

Not sure why this would fail? Shouldn't this path be created if it doesn't exist and if it already exists, then give a true for isdir()?

 isdir(pth2) || mkdir(pth2)

error:

IOError: mkdir("Y:/Canon Images for Dynamic Heart Phantom/Dynamic Phantom/clean_data/CONFIG 1^275/52/HR 60 KV 80 SEGMENT"; mode=0o777): file already exists (EEXIST)

uv_error@libuv.jl:97[inlined]
var"#mkdir#7"(::UInt16, ::typeof(mkdir), ::String)@file.jl:179
mkdir@file.jl:172[inlined]
top-level scope@Local: 1[inlined]

view this post on Zulip Felix Cremer (May 22 2021 at 19:12):

Could it be that your path is a file?

view this post on Zulip Gunnar Farnebäck (May 22 2021 at 19:34):

If you are missing multiple directory levels in the path, isdir will return false and mkdir fail. mkpath is your friend. But from the error message I agree that it looks likely that the path is a file.

view this post on Zulip Dale Black (May 22 2021 at 20:24):

Oh that's weird, some earlier code must have renamed a file to that path. I gotta figure out what I am doing wrong

view this post on Zulip Brenhin Keller (May 22 2021 at 20:25):

Also mkdir -p may be handy..

view this post on Zulip Gunnar Farnebäck (May 23 2021 at 12:20):

mkdir -p works the same way as Julia's mkpath.

view this post on Zulip Dale Black (May 24 2021 at 04:52):

Ahh I was wondering what that does but I didn’t want to expose my lack of understanding. Thanks to both of you!


Last updated: Oct 02 2023 at 04:34 UTC