Removes node.UTF8, node.RAW, node.ASCII enum versions of the encodings.
node.fs.read() now supports "raws" encoding.
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
<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
+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.
.\" 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)
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\.
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);
* 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)
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));
}
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 () {