diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-05-15 16:26:57 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-05-15 16:26:57 -0700 |
commit | 798e635cf912d778f08f8107d6d59fcd11b20082 (patch) | |
tree | b4627e55014a017c02d952c92feda76d745415ee /src/library.js | |
parent | 3afb3d53d70c6d9a3e84e488cfa986b8cd7b2733 (diff) |
support for reading files synchronously
Diffstat (limited to 'src/library.js')
-rw-r--r-- | src/library.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/library.js b/src/library.js index e3b6f964..eaa2332d 100644 --- a/src/library.js +++ b/src/library.js @@ -290,7 +290,14 @@ var Library = { }, open: function(filename) { var stream = _STDIO.filenames[filename]; - if (!stream) return -1; // assert(false, 'No information for file: ' + filename); + if (!stream) { + // Not already cached; try to load it right now + try { + return _STDIO.prepare(filename, readBinary(filename)); + } catch(e) { + return 0; + } + } var info = _STDIO.streams[stream]; info.position = info.error = info.eof = 0; return stream; |