summaryrefslogtreecommitdiff
path: root/lib/fs.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/fs.js')
-rw-r--r--lib/fs.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/fs.js b/lib/fs.js
index 0e915aaab..b92aa435b 100644
--- a/lib/fs.js
+++ b/lib/fs.js
@@ -543,7 +543,7 @@ fs.truncate = function(path, len, callback) {
len = 0;
}
callback = maybeCallback(callback);
- fs.open(path, 'w', function(er, fd) {
+ fs.open(path, 'r+', function(er, fd) {
if (er) return callback(er);
binding.ftruncate(fd, len, function(er) {
fs.close(fd, function(er2) {
@@ -562,7 +562,7 @@ fs.truncateSync = function(path, len) {
len = 0;
}
// allow error to be thrown, but still close fd.
- var fd = fs.openSync(path, 'w');
+ var fd = fs.openSync(path, 'r+');
try {
var ret = fs.ftruncateSync(fd, len);
} finally {