Difference between revisions of "Create a directory"

From CodeCodex

(Erlang)
(Implementations)
Line 56: Line 56:
 
<pre class="ruby">
 
<pre class="ruby">
 
Dir.mkdir('foo')
 
Dir.mkdir('foo')
 +
</pre>
 +
 +
=== Tcl ===
 +
<pre class="tcl">
 +
file mkdir foo
 
</pre>
 
</pre>
  
Line 66: Line 71:
 
[[Category:Python]]
 
[[Category:Python]]
 
[[Category:Ruby]]
 
[[Category:Ruby]]
 +
[[Category:Tcl]]
 
[[Category:I/O]]
 
[[Category:I/O]]

Revision as of 18:40, 17 February 2011

Implementations

Common Lisp

(ensure-directories-exist "/path/name/")

See the CLHS: ensure-directories-exist

Erlang

file:make_dir("foo").

Java

    // Create a directory; all ancestor directories must exist
    boolean success = (new File("directoryName")).mkdir();
    if (!success) {
        // Directory creation failed
    }
    
    // Create a directory; all non-existent ancestor directories are
    // automatically created
    success = (new File("directoryName")).mkdirs();
    if (!success) {
        // Directory creation failed
    }

OCaml

# Unix.mkdir "foo" 0o666;;
- : unit = ()

Perl

mkdir $dir;

use File::Path qw(mkpath);
mkpath $dir;

PHP

  mkdir('foo');

Python

import os
os.mkdir("foo", 0666)

Ruby

Dir.mkdir('foo')

Tcl

file mkdir foo