Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
bb1e8a6
deps: cherry-pick 6989b3f6d7 from V8 upstream
TimothyGu May 18, 2018
0c43ea4
deps: Upgrade node-inspect to 1.11.5
May 31, 2018
d388282
doc: add error check to fs example
evanlucas Feb 9, 2018
0b2d35c
test: add useful info to error msg and refactor
chinhuang007 Feb 2, 2018
edd8b2f
test: add crypto check to test-benchmark-tls
danbev Feb 12, 2018
bc66d4e
test: add multiline repl input regression test
cjihrig Feb 11, 2018
b01e470
doc: update crypo Certficate class.
antoine-amara Feb 11, 2018
a66434f
test: add lib path env when node_shared=true
yhwang Feb 2, 2018
92a90d1
test: wrap countdown callback in common.mustCall
Bamieh Nov 21, 2017
6a8c182
doc: remove extra space in README.md
Feb 16, 2018
7fbc6a4
test: try to connect after server was closed
Leko Jan 19, 2018
06b6507
test: reduce benchmark test run time
juggernaut451 Feb 14, 2018
077fb0a
test: make tls test more rigorous
bnoordhuis Feb 15, 2018
0ef0dbc
test: refactor of test-tls-over-http-tunnel
juggernaut451 Feb 14, 2018
8345f3c
test: refactor parallel/test-tls-addca
juggernaut451 Feb 15, 2018
4070782
test,benchmark,doc: enable dot-notation rule
BridgeAR Feb 13, 2018
8651766
doc: note that linting is required in releases.md
gibfahn Feb 14, 2018
b4fa857
doc: activate `no-multiple-empty-lines` rule
BridgeAR Feb 13, 2018
bf1ca7e
src: allow --perf-(basic-)?prof in NODE_OPTIONS
Leko Dec 11, 2017
c1c6253
crypto: allow passing null as IV unless required
tniessen Feb 7, 2018
c3a96ba
async_hooks: rename PromiseWrap.parentId
ofrobots Feb 8, 2018
a2e4940
fs: support as and as+ flags in stringToFlags()
Feb 15, 2018
5975c06
doc: add missing metadata for fs.open
tniessen Mar 25, 2018
bcaba81
tls: expose Finished messages in TLSSocket
codedot Mar 2, 2018
ae6e4bd
fs,net: emit 'ready' for fs streams and sockets
sameer-coder Mar 17, 2018
d3cc97b
deps: backport 804a693 from upstream V8
Jul 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fs: support as and as+ flags in stringToFlags()
PR-URL: #18801
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Matheus Marchini <matheus@sthima.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
Sarat Addepalli authored and MylesBorins committed Aug 7, 2018
commit a2e49409bc6e9bb9dd52464c3ef445209a454b5b
6 changes: 6 additions & 0 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1794,11 +1794,17 @@ The file is created if it does not exist.

* `'ax'` - Like `'a'` but fails if `path` exists.

* `'as'` - Open file for appending in synchronous mode.
The file is created if it does not exist.

* `'a+'` - Open file for reading and appending.
The file is created if it does not exist.

* `'ax+'` - Like `'a+'` but fails if `path` exists.

* `'as+'` - Open file for reading and appending in synchronous mode.
The file is created if it does not exist.

`mode` sets the file mode (permission and sticky bits), but only if the file was
created. It defaults to `0o666` (readable and writable).

Expand Down
4 changes: 4 additions & 0 deletions lib/internal/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ function stringToFlags(flag) {
case 'a' : return O_APPEND | O_CREAT | O_WRONLY;
case 'ax' : // Fall through.
case 'xa' : return O_APPEND | O_CREAT | O_WRONLY | O_EXCL;
case 'as' : // Fall through.
case 'sa' : return O_APPEND | O_CREAT | O_WRONLY | O_SYNC;

case 'a+' : return O_APPEND | O_CREAT | O_RDWR;
case 'ax+': // Fall through.
case 'xa+': return O_APPEND | O_CREAT | O_RDWR | O_EXCL;
case 'as+': // Fall through.
case 'sa+': return O_APPEND | O_CREAT | O_RDWR | O_SYNC;
}

throw new Error('Unknown file open flag: ' + flag);
Expand Down
4 changes: 4 additions & 0 deletions test/parallel/test-fs-open-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ assert.strictEqual(stringToFlags('wx+'), O_TRUNC | O_CREAT | O_RDWR | O_EXCL);
assert.strictEqual(stringToFlags('xw+'), O_TRUNC | O_CREAT | O_RDWR | O_EXCL);
assert.strictEqual(stringToFlags('ax'), O_APPEND | O_CREAT | O_WRONLY | O_EXCL);
assert.strictEqual(stringToFlags('xa'), O_APPEND | O_CREAT | O_WRONLY | O_EXCL);
assert.strictEqual(stringToFlags('as'), O_APPEND | O_CREAT | O_WRONLY | O_SYNC);
assert.strictEqual(stringToFlags('sa'), O_APPEND | O_CREAT | O_WRONLY | O_SYNC);
assert.strictEqual(stringToFlags('ax+'), O_APPEND | O_CREAT | O_RDWR | O_EXCL);
assert.strictEqual(stringToFlags('xa+'), O_APPEND | O_CREAT | O_RDWR | O_EXCL);
assert.strictEqual(stringToFlags('as+'), O_APPEND | O_CREAT | O_RDWR | O_SYNC);
assert.strictEqual(stringToFlags('sa+'), O_APPEND | O_CREAT | O_RDWR | O_SYNC);

('+ +a +r +w rw wa war raw r++ a++ w++ x +x x+ rx rx+ wxx wax xwx xxx')
.split(' ')
Expand Down