Re: [nodejs] fs.read

2012-04-01 Thread Matthew Hazlett
Thanks, that works! -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.co

Re: [nodejs] fs.read

2012-04-01 Thread Marak Squires
You need to read the documentation, you are not using fs module correctly. Here is corrected call from example: https://gist.github.com/2279298 On Sun, Apr 1, 2012 at 3:53 PM, Matthew Hazlett wrote: > Unfortunately, that did not solve the problem. > > I posted my code and its output / error in

Re: [nodejs] fs.read

2012-04-01 Thread Matt Patenaude
The problem is that you aren't using readFileSync correctly: it returns the result of the read, so instead of: fs.readFileSync(__dirname + '/' + filename, 'ascii', function (err, readData) { … }; … you should do: readData = fs.readFileSync(__dirname + '/' + filename, 'ascii); -Matt On

Re: [nodejs] fs.read

2012-04-01 Thread Matthew Hazlett
Unfortunately, that did not solve the problem. I posted my code and its output / error in Paste Bucket so you can see http://www.pastebucket.com/1968 Charlie McConnell Sunday, April 01, 2012 6:18 PM did you just leave out the callback to your fs.writeFile, o

Re: [nodejs] fs.read

2012-04-01 Thread Matthew Hazlett
ok, i'll try that.. thanks Charlie McConnell Sunday, April 01, 2012 6:18 PM did you just leave out the callback to your fs.writeFile, or did you not provide one? If you're using fs.readFile - an asynchronous method - and not providing a callback, that who

Re: [nodejs] fs.read

2012-04-01 Thread Charlie McConnell
did you just leave out the callback to your fs.writeFile, or did you not provide one? If you're using fs.readFile - an asynchronous method - and not providing a callback, that whole thing will be a race condition for you. Either use fs.readFileSync, or provide a callback and don't try to access t

Re: [nodejs] fs.read

2012-04-01 Thread Matthew Hazlett
It already is a string. I just don't get it :-( -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send emai

Re: [nodejs] fs.read

2012-04-01 Thread Marak Squires
Maybe try: JSON.parse(data.toString()) ? On Sun, Apr 1, 2012 at 3:09 PM, Matthew Hazlett wrote: > I have traced the error to the JSON statement. > > when I return JSON.parse(data) ; it blows up with an unexpected end of > file. > > When I console.log(JSON.parse(data)); it works fine. I'm conf

Re: [nodejs] fs.read

2012-04-01 Thread Matthew Hazlett
I have traced the error to the JSON statement. when I return JSON.parse(data) ; it blows up with an unexpected end of file. When I console.log(JSON.parse(data)); it works fine. I'm confused! Matthew Hazlett Sunday, April 01, 2012 4:25 PM This throws an error unexpe

[nodejs] fs.read

2012-04-01 Thread Matthew Hazlett
This throws an error unexpected end of file. fs.readFile(__dirname + '/' + filename, function (err, data) { if (err) throw err; console.log(data); }); This is a oneline file created by: fs.writeFile(__dirname + '/' + filename, JSON.stringif