Erlang Central

Platform Independent Path

From ErlangCentral Wiki


You want to create a directory in a platform independent way. The directory is several levels deep and you wish to create intermediate directories as necessary.


Use the ensure_dir procedure in Erlang's filelib module.

1> filelib:ensure_dir("/what/a/great/test").


Although the above directory tree looks like a POSIX file system, if this test is run on a Windows machine you will get the expected directory tree starting at the root of the current drive (usually C:). On a UNIX platform, you will get the expected directory tree.

As always your user permissions will limit what files and directories you are able to create or modify.