UNPKG

@trap_stevo/vault-link

Version:

Unlock the ultimate gateway to secure file and directory access. VaultLink transforms your files into guarded, time-sensitive links—sealed, tamper-proof, and effortlessly shareable. Elevate your storage game with unparalleled precision and flexibility, tu

31 lines (30 loc) • 808 B
"use strict"; const path = require("path"); const fs = require("fs"); function getFileMetadata(filePath) { const stats = fs.statSync(filePath); return { name: path.basename(filePath), type: stats.isDirectory() ? "directory" : "file", size: stats.size, createdAt: stats.birthtime, modifiedAt: stats.mtime }; } ; function listDirectoryContents(directoryPath, recursive = false) { const contents = fs.readdirSync(directoryPath).map(file => { const filePath = path.join(directoryPath, file); const fileInfo = getFileMetadata(filePath); if (fileInfo.type === "directory" && recursive) { fileInfo.contents = listDirectoryContents(filePath, true); } return fileInfo; }); return contents; } ; module.exports = { getFileMetadata, listDirectoryContents };