I need create subdirectory in specific directory.
In erlang docs i find only file:make_dir/1 which create dir in the project source dir. How can i create directory in other dir?
I find solution. Maybe it will be interesting somebody:
filelib:ensure_dir("/this/path/will/soon/exist/").
Thank you.
You can ensure that a directory exists (and create it if it doesn't, which is what you're looking for) using filelib:ensure_dir
.
Example:
filelib:ensure_dir("/this/path/will/soon/exist/")
References:
The documentation must have been unclear as you can use file:make_dir/1
to create any directory which you would normally be allowed to create. It does not create all directories in the path, this you have to do explicitly yourself.
Using filelib:ensure_dir/1
with a path terminated by "/"
is not documented but it is explicitly handled in the code so I doubt that it will go away.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With