| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5f7fad2 commit 39f1b89
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2402,7 +2402,7 @@ static void ReadFileUtf8(const FunctionCallbackInfo<Value>& args) { | |||
| 2402 | 2402 | if (CheckOpenPermissions(env, path, flags).IsNothing()) return; | |
| 2403 | 2403 | ||
| 2404 | 2404 | FS_SYNC_TRACE_BEGIN(open); | |
| 2405 | - file = uv_fs_open(nullptr, &req, *path, flags, O_RDONLY, nullptr); | ||
| 2405 | + file = uv_fs_open(nullptr, &req, *path, flags, 0666, nullptr); | ||
| 2406 | 2406 | FS_SYNC_TRACE_END(open); | |
| 2407 | 2407 | if (req.result < 0) { | |
| 2408 | 2408 | uv_fs_req_cleanup(&req); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,11 +24,37 @@ require('../common'); | |||
| 24 | 24 | const assert = require('assert'); | |
| 25 | 25 | const fs = require('fs'); | |
| 26 | 26 | const fixtures = require('../common/fixtures'); | |
| 27 | + const tmpdir = require('../common/tmpdir'); | ||
| 27 | 28 | ||
| 28 | 29 | const fn = fixtures.path('elipses.txt'); | |
| 30 | + tmpdir.refresh(); | ||
| 29 | 31 | ||
| 30 | 32 | const s = fs.readFileSync(fn, 'utf8'); | |
| 31 | 33 | for (let i = 0; i < s.length; i++) { | |
| 32 | 34 | assert.strictEqual(s[i], '\u2026'); | |
| 33 | 35 | } | |
| 34 | 36 | assert.strictEqual(s.length, 10000); | |
| 37 | + | ||
| 38 | + // Test file permissions set for readFileSync() in append mode. | ||
| 39 | + { | ||
| 40 | + const expectedMode = 0o666 & ~process.umask(); | ||
| 41 | + | ||
| 42 | + for (const test of [ | ||
| 43 | + { }, | ||
| 44 | + { encoding: 'ascii' }, | ||
| 45 | + { encoding: 'base64' }, | ||
| 46 | + { encoding: 'hex' }, | ||
| 47 | + { encoding: 'latin1' }, | ||
| 48 | + { encoding: 'uTf8' }, // case variation | ||
| 49 | + { encoding: 'utf16le' }, | ||
| 50 | + { encoding: 'utf8' }, | ||
| 51 | + ]) { | ||
| 52 | + const opts = { ...test, flag: 'a+' }; | ||
| 53 | + const file = tmpdir.resolve(`testReadFileSyncAppend${opts.encoding ?? ''}.txt`); | ||
| 54 | + const variant = `for '${file}'`; | ||
| 55 | + | ||
| 56 | + const content = fs.readFileSync(file, opts); | ||
| 57 | + assert.strictEqual(opts.encoding ? content : content.toString(), '', `file contents ${variant}`); | ||
| 58 | + assert.strictEqual(fs.statSync(file).mode & 0o777, expectedMode, `file permissions ${variant}`); | ||
| 59 | + } | ||
| 60 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments