wqx081 / v8cgi

Automatically exported from code.google.com/p/v8cgi
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

binary data into filesystem #89

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

var f = new File("c:\\a.js")
f.open("wb")                    
f.write([10, 20, 30])
f.close()

What is the expected output? What do you see instead?
A file with 3 bytes with values 10 20 30
Array -> toString -> 10,20,30

What version of the product are you using? On what operating system?
0.9.0

Please provide any additional information below.
System: Windows Xp Professional

Original issue reported on code.google.com by nanoyo...@yahoo.it on 17 Feb 2011 at 7:23

GoogleCodeExporter commented 8 years ago
In order to handle binary data, use the new Buffer class, introduced in v8cgi 
0.9.0. Your file-writing example can be rewritten like this:

var Buffer = require("binary").Buffer;
var binaryData = new Buffer([10, 20, 30]);
f.write(binaryData);

Original comment by ondrej.zara on 17 Feb 2011 at 1:23