diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-10-28 12:09:13 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-10-28 12:09:13 -0700 |
commit | 000f6946aa7d0240adbde91e4ace52311849ee0f (patch) | |
tree | e5c42073bfd2e458c2d4735da9bf0064e9f38af9 /src | |
parent | 50637a70c722ef625bb36b7ede957224a4e54b90 (diff) |
reuse node in open call from createDataFile
Diffstat (limited to 'src')
-rw-r--r-- | src/library_fs.js | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/library_fs.js b/src/library_fs.js index 70902834..5d960462 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -772,7 +772,6 @@ mergeInto(LibraryManager.library, { }); }, open: function(path, flags, mode, fd_start, fd_end) { - path = PATH.normalize(path); flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags; mode = typeof mode === 'undefined' ? 0666 : mode; if ((flags & {{{ cDefine('O_CREAT') }}})) { @@ -781,13 +780,18 @@ mergeInto(LibraryManager.library, { mode = 0; } var node; - try { - var lookup = FS.lookupPath(path, { - follow: !(flags & {{{ cDefine('O_NOFOLLOW') }}}) - }); - node = lookup.node; - } catch (e) { - // ignore + if (typeof path === 'object') { + node = path; + } else { + path = PATH.normalize(path); + try { + var lookup = FS.lookupPath(path, { + follow: !(flags & {{{ cDefine('O_NOFOLLOW') }}}) + }); + node = lookup.node; + } catch (e) { + // ignore + } } // perhaps we need to create the node if ((flags & {{{ cDefine('O_CREAT') }}})) { @@ -1216,7 +1220,7 @@ mergeInto(LibraryManager.library, { } // make sure we can write to the file FS.chmod(node, mode | {{{ cDefine('S_IWUGO') }}}); - var stream = FS.open(path, 'w'); + var stream = FS.open(node, 'w'); FS.write(stream, data, 0, data.length, 0, canOwn); FS.close(stream); FS.chmod(path, mode); |