More docs. Add rmdir and unlink.
authorRyan <ry@tinyclouds.org>
Tue, 26 May 2009 10:11:31 +0000 (12:11 +0200)
committerRyan <ry@tinyclouds.org>
Tue, 26 May 2009 10:11:31 +0000 (12:11 +0200)
src/file.cc
website/node.html

index f366ea6..7c69bf6 100644 (file)
@@ -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)
 {
@@ -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);
 
index d0b5366..7095c3f 100644 (file)
@@ -227,7 +227,7 @@ pool</a>
 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>
@@ -266,15 +266,29 @@ node.fs.rename("/tmp/hello", "/tmp/world", function (status) {
 </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>