function makeDirectoryListing(pathPrefix, pathSuffix, request) {
    let pathSuffixParts = libpath.normalize(pathSuffix).split(libpath.sep);
    if (pathSuffixParts[0] === "..") {
        throw 400;
    }
    if (pathSuffixParts[pathSuffixParts.length - 1] !== "") {
        pathSuffixParts.push("");
    }
    let fullPath = libpath.join(pathPrefix, ...pathSuffixParts);
    if (!libfs.existsSync(fullPath) || !libfs.statSync(fullPath).isDirectory()) {
        throw 404;
    }
    let entries = libfs.readdirSync(fullPath, { withFileTypes: true });
    let directories = entries
        .filter((entry) => entry.isDirectory())
        .map((entry) => {
        return {
            name: entry.name
        };
    })
        .sort((one, two) => one.name.localeCompare(two.name));
    let files = entries
        .filter((entry) => entry.isFile())
        .map((entry) => {
        let stat = libfs.statSync(libpath.join(fullPath, entry.name));
        return {
            name: entry.name,
            size: stat.size,
            timestamp: stat.mtime.valueOf()
        };
    })
        .sort((one, two) => one.name.localeCompare(two.name));
    let components = pathSuffixParts;
    return {
        components,
        directories,
        files
    };
}
// TODO: Move to Nexus in v6.
Move to Nexus in v6.
Move to Nexus in v6 .
function makeDirectoryListing(pathPrefix, pathSuffix, request) {
    let pathSuffixParts = libpath.normalize(pathSuffix).split(libpath.sep);
    if (pathSuffixParts[0] === "..") {
        throw 400;
    }
    if (pathSuffixParts[pathSuffixParts.length - 1] !== "") {
        pathSuffixParts.push("");
    }
    let fullPath = libpath.join(pathPrefix, ...pathSuffixParts);
    if (!libfs.existsSync(fullPath) || !libfs.statSync(fullPath).isDirectory()) {
        throw 404;
    }
    let entries = libfs.readdirSync(fullPath, { withFileTypes: true });
    let directories = entries
        .filter((entry) => entry.isDirectory())
        .map((entry) => {
        return {
            name: entry.name
        };
    })
        .sort((one, two) => one.name.localeCompare(two.name));
    let files = entries
        .filter((entry) => entry.isFile())
        .map((entry) => {
        let stat = libfs.statSync(libpath.join(fullPath, entry.name));
        return {
            name: entry.name,
            size: stat.size,
            timestamp: stat.mtime.valueOf()
        };
    })
        .sort((one, two) => one.name.localeCompare(two.name));
    let components = pathSuffixParts;
    return {
        components,
        directories,
        files
    };
}
function makeDirectoryListing ( pathPrefix , pathSuffix , request ) { let pathSuffixParts = libpath . normalize ( pathSuffix ) . split ( libpath . sep ) ; if ( pathSuffixParts [ 0 ] === ".." ) { throw 400 ; } if ( pathSuffixParts [ pathSuffixParts . length - 1 ] !== "" ) { pathSuffixParts . push ( "" ) ; } let fullPath = libpath . join ( pathPrefix , ... pathSuffixParts ) ; if ( ! libfs . existsSync ( fullPath ) || ! libfs . statSync ( fullPath ) . isDirectory ( ) ) { throw 404 ; } let entries = libfs . readdirSync ( fullPath , { withFileTypes : true } ) ; let directories = entries . filter ( ( entry ) => entry . isDirectory ( ) ) . map ( ( entry ) => { return { name : entry . name } ; } ) . sort ( ( one , two ) => one . name . localeCompare ( two . name ) ) ; let files = entries . filter ( ( entry ) => entry . isFile ( ) ) . map ( ( entry ) => { let stat = libfs . statSync ( libpath . join ( fullPath , entry . name ) ) ; return { name : entry . name , size : stat . size , timestamp : stat . mtime . valueOf ( ) } ; } ) . sort ( ( one , two ) => one . name . localeCompare ( two . name ) ) ; let components = pathSuffixParts ; return { components , directories , files } ; }
TODO: Move to Nexus in v6.
TODO : Move to Nexus in v6 .