Create Deep Directory

From Erlang Community

[edit] Problem

You want to be able to create a directory without having to verify each parent element of the directory exists.

[edit] Solution

The ensure_dir function of the filelib module checks that all parent directories for a given directory name exists, creating any elements if needed.

1> filelib:ensure_dir("/this/path/will/soon/exist").
ok

[edit] Discussion

This is one area where Erlang makes it very easy. This useful library module helps us avoid a lot of repetitive boilerplate code.

Erlang/OTP Projects
Personal tools