API: node.fs.read() takes a normal encoding parameter.
authorRyan Dahl <ry@tinyclouds.org>
Sun, 13 Sep 2009 16:31:17 +0000 (18:31 +0200)
committerRyan Dahl <ry@tinyclouds.org>
Sun, 13 Sep 2009 16:31:17 +0000 (18:31 +0200)
Removes node.UTF8, node.RAW, node.ASCII enum versions of the encodings.
node.fs.read() now supports "raws" encoding.

doc/api.html
doc/api.txt
doc/node.1
src/constants.cc
src/file.cc
src/file.js

index 5483bc8..dcae34f 100644 (file)
@@ -815,8 +815,6 @@ Read data from the file specified by <tt>fd</tt>.
 bytes to read.</p></div>\r
 <div class="paragraph"><p><tt>position</tt> is an integer specifying where to begin\r
 reading from in the file.</p></div>\r
-<div class="paragraph"><p><tt>encoding</tt> is either <tt>node.UTF8</tt>\r
-or <tt>node.RAW</tt>.</p></div>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1863,7 +1861,7 @@ init (Handle&lt;Object&gt; target)
 <div id="footer">\r
 <div id="footer-text">\r
 Version 0.1.10<br />\r
-Last updated 2009-09-12 19:12:41 CEST\r
+Last updated 2009-09-13 18:25:27 CEST\r
 </div>\r
 </div>\r
 </body>\r
index 0c46f51..9928e25 100644 (file)
@@ -499,9 +499,6 @@ bytes to read.
 +position+ is an integer specifying where to begin
 reading from in the file.
 +
-+encoding+ is either +node.UTF8+
-or +node.RAW+.
-+
 - on success: returns +data, bytes_read+, what was read from the file.
 - on error: no parameters.
 
index 3dfc899..9ae853d 100644 (file)
@@ -1,11 +1,11 @@
 .\"     Title: node
 .\"    Author: 
 .\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/>
-.\"      Date: 09/12/2009
+.\"      Date: 09/13/2009
 .\"    Manual: 
 .\"    Source: 
 .\"
-.TH "NODE" "1" "09/12/2009" "" ""
+.TH "NODE" "1" "09/13/2009" "" ""
 .\" disable hyphenation
 .nh
 .\" disable justification (adjust text to left margin only)
@@ -732,12 +732,6 @@ is an integer specifying the number of bytes to read\.
 position
 is an integer specifying where to begin reading from in the file\.
 .sp
-encoding
-is either
-node\.UTF8
-or
-node\.RAW\.
-.sp
 .RS 4
 \h'-04'\(bu\h'+03'on success: returns
 data, bytes_read, what was read from the file\.
index 38ece60..f486f11 100644 (file)
@@ -13,10 +13,6 @@ namespace node {
 using namespace v8;
 
 void DefineConstants(Handle<Object> target) {
-  NODE_DEFINE_CONSTANT(target, RAW);
-  NODE_DEFINE_CONSTANT(target, UTF8);
-  NODE_DEFINE_CONSTANT(target, ASCII);
-
   // file access modes
   NODE_DEFINE_CONSTANT(target, O_RDONLY);
   NODE_DEFINE_CONSTANT(target, O_WRONLY);
index aa8e645..c5edcb8 100644 (file)
@@ -350,7 +350,7 @@ Write (const Arguments& args)
  * 1 length    integer. length to read
  * 2 position  if integer, position to read from in the file.
  *             if null, read from the current position
- * 3 encoding  either node.UTF8 or node.RAW
+ * 3 encoding
  */
 static Handle<Value>
 Read (const Arguments& args)
@@ -365,10 +365,7 @@ Read (const Arguments& args)
   size_t len = args[1]->IntegerValue();
   off_t pos = args[2]->IsNumber() ? args[2]->IntegerValue() : -1;
 
-  enum encoding encoding = RAW;
-  if (args[3]->IsInt32()) {
-    encoding = static_cast<enum encoding>(args[3]->Int32Value());
-  }
+  enum encoding encoding = ParseEncoding(args[3]);
 
   return scope.Close(EIOPromise::Read(fd, len, pos, encoding));
 }
index 71094d4..25a8f89 100644 (file)
@@ -8,11 +8,9 @@ node.fs.cat = function (path, encoding) {
   var open_promise = node.fs.open(path, node.O_RDONLY, 0666);
   var cat_promise = new node.Promise();
 
-  encoding = (encoding === "raw" ? node.RAW : node.UTF8);
-
   open_promise.addErrback(function () { cat_promise.emitError(); });
   open_promise.addCallback(function (fd) {
-    var content = (encoding === node.UTF8 ? "" : []);
+    var content = (encoding === "raw" ? [] : "");
     var pos = 0;
 
     function readChunk () {