@globalfishingwatch/gdal3.js
Version:
gdal3.js is a port of Gdal applications (**gdal_translate**, **ogr2ogr**, **gdal_rasterize**, **gdalwarp**, **gdaltransform**) to Webassembly. It allows you to convert raster and vector geospatial data to various formats and coordinate systems.
15 lines (12 loc) • 623 B
JavaScript
import { GDALFunctions } from '../../allCFunctions';
import { OUTPUTPATH } from './const';
export default function getFileList(path = OUTPUTPATH.substr(1)) {
const contents = path.split('/').reduce((accumulator, currentValue) => accumulator.contents[currentValue], GDALFunctions.Module.FS.root).contents;
const fileList = [];
Object.keys(contents).forEach((name) => {
const obj = contents[name];
if (obj.usedBytes) fileList.push({ path: `/${path}/${name}`, size: obj.usedBytes });
else if (obj.contents) fileList.push(...getFileList(`${path}/${name}`));
});
return fileList;
}