심볼릭 링크 폴더도 표시

This commit is contained in:
2026-05-22 16:25:03 +09:00
parent 0b9b2dea8b
commit 77622f8c6c
+26 -7
View File
@@ -46,15 +46,14 @@ function register(mainWindow) {
try { try {
const entries = fs.readdirSync(folderPath, { withFileTypes: true }); const entries = fs.readdirSync(folderPath, { withFileTypes: true });
return entries return entries
.filter(e => e.isDirectory() && !e.name.startsWith('.')) .filter(e => !e.name.startsWith('.') && isDirectoryEntry(folderPath, e))
.map(e => { .map(e => {
const fullPath = path.join(folderPath, e.name); const fullPath = path.join(folderPath, e.name);
let hasChildren = false; return {
try { name: e.name,
hasChildren = fs.readdirSync(fullPath, { withFileTypes: true }) path: fullPath,
.some(c => c.isDirectory() && !c.name.startsWith('.')); hasChildren: hasVisibleDirectoryChildren(fullPath),
} catch {} };
return { name: e.name, path: fullPath, hasChildren };
}) })
.sort((a, b) => a.name.localeCompare(b.name)); .sort((a, b) => a.name.localeCompare(b.name));
} catch { return null; } } catch { return null; }
@@ -90,4 +89,24 @@ function register(mainWindow) {
}); });
} }
function isDirectoryEntry(parentPath, entry) {
if (entry.isDirectory()) return true;
if (!entry.isSymbolicLink()) return false;
try {
return fs.statSync(path.join(parentPath, entry.name)).isDirectory();
} catch {
return false;
}
}
function hasVisibleDirectoryChildren(folderPath) {
try {
return fs.readdirSync(folderPath, { withFileTypes: true })
.some(entry => !entry.name.startsWith('.') && isDirectoryEntry(folderPath, entry));
} catch {
return false;
}
}
module.exports = { register }; module.exports = { register };