diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/docx/files.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/docx/files.js b/lib/docx/files.js new file mode 100644 index 0000000..6596a01 --- /dev/null +++ b/lib/docx/files.js @@ -0,0 +1,27 @@ +var fs = require("fs"); + +var promises = require("../promises"); + + +exports.Files = Files; + + +function Files() { + function read(path, encoding) { + // TODO: check whether this works for Windows file URIs + var fileUriPrefix = "file:///"; + if (startsWith(path, fileUriPrefix)) { + return readFile(path.slice(fileUriPrefix.length - 1), encoding); + } + } + + return { + read: read + }; +} + +var readFile = promises.promisify(fs.readFile.bind(fs)); + +function startsWith(string, search) { + return string.indexOf(search) === 0; +} |
