e r l a n g : c o o k b o o k

/ Erlang.FileCreateDeepDirectory

This Web


WebHome 
WebChanges 
TOC
NewRecipe 
WebTopicList 
WebStatistics 

All Webs


Chicken
Cookbook
Erlang
Know
Main
Plugins
Sandbox
Scm
TWiki  

Erlang Links


Erlang.org
Erlang Wiki
ErlMan
Erlang Wiki
The Jungerl
Erlang-fr.org
Joe Armstrong
Lambda the Ultimate

Erlang Web Ring


[Prev]: Joe Armstrong's Page
[Next]: Joe Armstrong's Page

Creating Directories Including Parent Directories

Problem

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

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

Discussion

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


Comments about this recipe

Contributors

-- BrentAFulgham - 03 Sep 2004

CookbookForm
TopicType: Recipe
ParentTopic: FileRecipes
TopicOrder: 090

 
 
Copyright © 2004 by the contributing authors. All material on the Erlang Cookbook web site is the property of the contributing authors.
This material can be redistributed and/or modified under the terms of the GNU Lesser General Public License (LGPL), version 2.1, as published by the Free Software Foundation.
Ideas, requests, problems regarding Schematics Cookbook? Send feedback.
/ You are Main.guest