aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-06-11 17:34:30 -0700
committerAlon Zakai <alonzakai@gmail.com>2014-06-11 17:34:30 -0700
commitf0c0f89da70c1924237b4befffef0a6745579e39 (patch)
tree8bca55c131a0c28e475c16e498a0996e0ffb0f26 /src
parent6ef510e386345042ae720269c6c120a7c15252db (diff)
parent00a321f5955538dd9eef324901d7e3126600ddaa (diff)
Merge pull request #2424 from gsathya/fix_append_bug
Fix append bug
Diffstat (limited to 'src')
-rw-r--r--src/library_fs.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/library_fs.js b/src/library_fs.js
index 1fff6348..d825892c 100644
--- a/src/library_fs.js
+++ b/src/library_fs.js
@@ -1077,6 +1077,10 @@ mergeInto(LibraryManager.library, {
if (!stream.stream_ops.write) {
throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
}
+ if (stream.flags & {{{ cDefine('O_APPEND') }}}) {
+ // seek to the end before writing in append mode
+ FS.llseek(stream, 0, {{{ cDefine('SEEK_END') }}});
+ }
var seeking = true;
if (typeof position === 'undefined') {
position = stream.position;
@@ -1084,10 +1088,6 @@ mergeInto(LibraryManager.library, {
} else if (!stream.seekable) {
throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
}
- if (stream.flags & {{{ cDefine('O_APPEND') }}}) {
- // seek to the end before writing in append mode
- FS.llseek(stream, 0, {{{ cDefine('SEEK_END') }}});
- }
var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
if (!seeking) stream.position += bytesWritten;
try {