Erlang Central

Create Deep Directory

From ErlangCentral Wiki


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


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").


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