심볼릭 링크 폴더도 표시
This commit is contained in:
+26
-7
@@ -46,15 +46,14 @@ function register(mainWindow) {
|
||||
try {
|
||||
const entries = fs.readdirSync(folderPath, { withFileTypes: true });
|
||||
return entries
|
||||
.filter(e => e.isDirectory() && !e.name.startsWith('.'))
|
||||
.filter(e => !e.name.startsWith('.') && isDirectoryEntry(folderPath, e))
|
||||
.map(e => {
|
||||
const fullPath = path.join(folderPath, e.name);
|
||||
let hasChildren = false;
|
||||
try {
|
||||
hasChildren = fs.readdirSync(fullPath, { withFileTypes: true })
|
||||
.some(c => c.isDirectory() && !c.name.startsWith('.'));
|
||||
} catch {}
|
||||
return { name: e.name, path: fullPath, hasChildren };
|
||||
return {
|
||||
name: e.name,
|
||||
path: fullPath,
|
||||
hasChildren: hasVisibleDirectoryChildren(fullPath),
|
||||
};
|
||||
})
|
||||
.sort((a, b) => a.name.localeCompare(b.name));
|
||||
} 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 };
|
||||
|
||||
Reference in New Issue
Block a user