Repository navigation
openSync/writeSync/closeSync produces empty file #7879
Description
Activity
- addedfsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.
on Jul 26, 2016 The
writeSynccall returns 0, which means no data was written. Didn't have time to investigate further.fs.writeSync(fd, buf, 0, buf.length);should work; right now,fs.writeSyncalways uses thelengthargument, even when it’sundefined. I doubt that’s intentional, though.Sounds like you've run into the same problem for
writeSyncas I did withwritea few days ago: #7856@papandreou: looks alike. Will the fix there also fix my issue?
I don't think it will in its current state, no. I'm on holiday for the next week, but will make sure to pick it up if noone else has landed a fix in the mean time. It's weird, seems like this bug has been there since at least 0.6. It really is the most basic form of
fs.write(Sync)-- and now the two of us both discover it within half a week :)@papandreou, alternatevly you could change this here
so thatLine 1001 in c86c1ee
// Wrapper for write(2). WriteBufferaccepts the following spec:// Wrapper for write(2). // // bytesWritten = write(fd, buffer, offset, length, position, callback) // 0 fd integer. file descriptor // 1 buffer the data to write // 2 offset where in the buffer to start from if integer, 0 if undefined or null // 3 length how much to write if integer, buffer length minus offset if undefined or null // 4 position if integer, position to write at in the file. // if null or undefined, write from the current positionAs I understand
WriteBufferis common meeting point for allwriteandwriteSyncfunctions. Thos functions could be simplified afterWriteBuffergets new functionality.Fixed by #7856 (released in 7.2.0). This issue can be closed now.
Code:
produces empty file. Expected is that it writes whole buffer. Note that
fs.writeSync(fd, "Was here.\n");writes whole string.v6.2.2
Darwin MacBook-Pro-3.local 14.5.0 Darwin Kernel Version 14.5.0: Thu Apr 21 20:40:54 PDT 2016; root:xnu-2782.50.3~1/RELEASE_X86_64 x86_64
fs(?)