Skip to content

Commit 16537b9

Browse files
committed
fs: tests and docs for additional modes as and as+
1 parent bc65182 commit 16537b9

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

doc/api/fs.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,11 +2019,17 @@ The file is created if it does not exist.
20192019

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

2022+
* `'as'` - Open file for appending in synchronous mode.
2023+
The file is created if it does not exist.
2024+
20222025
* `'a+'` - Open file for reading and appending.
20232026
The file is created if it does not exist.
20242027

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

2030+
* `'as+'` - Open file for reading and appending in synchronous mode.
2031+
The file is created if it does not exist.
2032+
20272033
`mode` sets the file mode (permission and sticky bits), but only if the file was
20282034
created. It defaults to `0o666` (readable and writable).
20292035

@@ -3907,11 +3913,17 @@ The file is created if it does not exist.
39073913

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

3916+
* `'as'` - Open file for appending in synchronous mode.
3917+
The file is created if it does not exist.
3918+
39103919
* `'a+'` - Open file for reading and appending.
39113920
The file is created if it does not exist.
39123921

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

3924+
* `'as+'` - Open file for reading and appending in synchronous mode.
3925+
The file is created if it does not exist.
3926+
39153927
`mode` sets the file mode (permission and sticky bits), but only if the file was
39163928
created. It defaults to `0o666` (readable and writable).
39173929

test/parallel/test-fs-open-flags.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,12 @@ assert.strictEqual(stringToFlags('wx+'), O_TRUNC | O_CREAT | O_RDWR | O_EXCL);
5656
assert.strictEqual(stringToFlags('xw+'), O_TRUNC | O_CREAT | O_RDWR | O_EXCL);
5757
assert.strictEqual(stringToFlags('ax'), O_APPEND | O_CREAT | O_WRONLY | O_EXCL);
5858
assert.strictEqual(stringToFlags('xa'), O_APPEND | O_CREAT | O_WRONLY | O_EXCL);
59+
assert.strictEqual(stringToFlags('as'), O_APPEND | O_CREAT | O_WRONLY | O_SYNC);
60+
assert.strictEqual(stringToFlags('sa'), O_APPEND | O_CREAT | O_WRONLY | O_SYNC);
5961
assert.strictEqual(stringToFlags('ax+'), O_APPEND | O_CREAT | O_RDWR | O_EXCL);
6062
assert.strictEqual(stringToFlags('xa+'), O_APPEND | O_CREAT | O_RDWR | O_EXCL);
63+
assert.strictEqual(stringToFlags('as+'), O_APPEND | O_CREAT | O_RDWR | O_SYNC);
64+
assert.strictEqual(stringToFlags('sa+'), O_APPEND | O_CREAT | O_RDWR | O_SYNC);
6165

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

0 commit comments

Comments
 (0)