Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
More docs. Add rmdir and unlink.
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed May 26, 2009
1 parent a9f29cd commit c326614
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 9 deletions.
34 changes: 30 additions & 4 deletions src/file.cc
Expand Up @@ -84,6 +84,30 @@ static Handle<Value> Rename (const Arguments& args)
return Undefined();
}

DEFINE_SIMPLE_CB(Unlink)
static Handle<Value> Unlink (const Arguments& args)
{
if (args.Length() < 1 || !args[0]->IsString())
return ThrowException(BAD_ARGUMENTS);
HandleScope scope;
String::Utf8Value path(args[0]->ToString());
MAKE_CALLBACK_PTR
eio_unlink(*path, EIO_PRI_DEFAULT, AfterUnlink, callback);
return Undefined();
}

DEFINE_SIMPLE_CB(RMDir)
static Handle<Value> RMDir (const Arguments& args)
{
if (args.Length() < 1 || !args[0]->IsString())
return ThrowException(BAD_ARGUMENTS);
HandleScope scope;
String::Utf8Value path(args[0]->ToString());
MAKE_CALLBACK_PTR
eio_rmdir(*path, EIO_PRI_DEFAULT, AfterRMDir, callback);
return Undefined();
}

static int
AfterOpen (eio_req *req)
{
Expand Down Expand Up @@ -355,13 +379,15 @@ File::Initialize (Handle<Object> target)
{
HandleScope scope;

// file system methods
NODE_SET_METHOD(target, "rename", Rename);
NODE_SET_METHOD(target, "stat", Stat);
// POSIX Wrappers
NODE_SET_METHOD(target, "close", Close);
NODE_SET_METHOD(target, "open", Open);
NODE_SET_METHOD(target, "write", Write);
NODE_SET_METHOD(target, "read", Read);
NODE_SET_METHOD(target, "rename", Rename);
NODE_SET_METHOD(target, "rmdir", RMDir);
NODE_SET_METHOD(target, "stat", Stat);
NODE_SET_METHOD(target, "unlink", Unlink);
NODE_SET_METHOD(target, "write", Write);

NODE_SET_METHOD(target, "strerror", StrError);

Expand Down
24 changes: 19 additions & 5 deletions website/node.html
Expand Up @@ -227,7 +227,7 @@ <h3 id="files">node.fs</h3>
to execute file system calls.

<p>This part of the API is split into two parts: simple wrappers around
standard POSIX file I/O functions, and a user-friendly <code>File</code>
standard POSIX file I/O functions and a user-friendly <code>File</code>
object.

<h4 id="file_wrappers">POSIX Wrappers</h4>
Expand Down Expand Up @@ -266,15 +266,29 @@ <h4 id="file_wrappers">POSIX Wrappers</h4>
</pre>

<dl>
<dt><code>node.fs.rename(path1, path2, on_completion)</code></dt>
<dt><code>node.fs.rename(path1, path2, on_completion(status))</code></dt>
<dd>
<code>on_completion(status)</code>
<a
href="http://opengroup.org/onlinepubs/007908799/xsh/rename.html">rename(2)</a>
</dd>

<dt><code>node.fs.stat(path, on_completion)</code></dt>
<dt><code>node.fs.stat(path, on_completion(status, stats))</code></dt>
<dd>
<code>on_completion(status, stat_object)</code>
<a href="http://opengroup.org/onlinepubs/007908799/xsh/stat.html">stat(2)</a>
</dd>

<dt><code>node.fs.unlink(path, on_completion(status))</code></dt>
<dd>
<a
href="http://opengroup.org/onlinepubs/007908799/xsh/unlink.html">unlink(2)</a>
</dd>

<dt><code>node.fs.rmdir(path, on_completion(status))</code></dt>
<dd>
<a
href="http://opengroup.org/onlinepubs/007908799/xsh/rmdir.html">rmdir(2)</a>
</dd>

</dl>

<h4 id="file_file"><code>node.fs.File</code></h4>
Expand Down

0 comments on commit c326614

Please sign in to comment.