"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Files = void 0; const promises_1 = require("fs/promises"); const hash_1 = require("../hash"); const path_1 = require("path"); const videoExtensions = [ '.mp4', '.mkv', '.mov' ]; const imageExtensions = [ '.jpg', '.jpeg', '.png', '.tif', '.tiff', '.bmp' ]; class Files { static async exists(path) { try { await (0, promises_1.access)(path); return true; } catch { return false; } } static async enumerateSequences(path) { const dirs = []; let all; let stats; let dirPath; path = await (0, promises_1.realpath)(path); try { all = await (0, promises_1.readdir)(path); } catch (err) { throw err; } for (let elem of all) { dirPath = (0, path_1.join)(path, elem); try { stats = await (0, promises_1.lstat)(dirPath); if (stats.isDirectory()) { dirs.push({ path: dirPath, hash: hash_1.Hashes.stringHash(dirPath), name: (0, path_1.basename)(dirPath) }); } } catch (err) { // } } return dirs; } static async enumerateVideos(path) { const videos = []; let all; let stats; let filePath; path = await (0, promises_1.realpath)(path); try { all = await (0, promises_1.readdir)(path); } catch (err) { throw err; } for (let elem of all) { filePath = (0, path_1.join)(path, elem); try { stats = await (0, promises_1.lstat)(filePath); if (stats.isFile() && videoExtensions.indexOf((0, path_1.extname)((0, path_1.basename)(elem).toLowerCase())) !== -1) { videos.push({ path: filePath, hash: hash_1.Hashes.stringHash(filePath), name: (0, path_1.basename)(filePath) }); } } catch (err) { // } } return videos; } static async enumerateSequence(path) { const imgs = []; let all; let stats; let filePath; path = await (0, promises_1.realpath)(path); try { all = await (0, promises_1.readdir)(path); } catch (err) { throw err; } for (let elem of all) { filePath = (0, path_1.join)(path, elem); try { stats = await (0, promises_1.lstat)(filePath); if (stats.isFile() && imageExtensions.indexOf((0, path_1.extname)((0, path_1.basename)(elem).toLowerCase())) !== -1) { imgs.push({ path: filePath, hash: hash_1.Hashes.stringHash(filePath), name: (0, path_1.basename)(filePath) }); } } catch (err) { // } } return imgs; } } exports.Files = Files; module.exports = { Files }; //# sourceMappingURL=index.js.map