aboutsummaryrefslogtreecommitdiff
path: root/lib/docx/files.js
blob: 6596a0191ea61b835091509766569b2d7b91c54c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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;
}