aboutsummaryrefslogtreecommitdiff
path: root/src/library_fs.js
diff options
context:
space:
mode:
authorSathyanarayanan Gunasekaran <gsathya.ceg@gmail.com>2014-06-11 16:37:42 -0700
committerSathyanarayanan Gunasekaran <gsathya.ceg@gmail.com>2014-06-11 16:37:42 -0700
commit5f81e122c03f37e0c8acb039b4ab2af301e7bef6 (patch)
tree126bdd67eeb871661b11ba01e2e1712e564b67a8 /src/library_fs.js
parent6ef510e386345042ae720269c6c120a7c15252db (diff)
change value of position after seeking
Diffstat (limited to 'src/library_fs.js')
-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 {