You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
1.4 KiB
27 lines
1.4 KiB
const icons = require('../../json/icons.json');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
module.exports = (fpath, name) => {
|
|
let icon;
|
|
try {
|
|
if (fs.lstatSync(fpath).isDirectory()) {
|
|
if (fs.existsSync(`./assets/icons/folder/folder-${name.toLowerCase()}`)) {icon = `./assets/icons/folder/folder-${name.toLowerCase()}`;}
|
|
else {icon = './assets/icons/base/folder.svg';}
|
|
}
|
|
/*else if (['.lnk'].includes(path.extname(file))) {
|
|
try {isrc = shell.readShortcutLink(`${dir}\\${file}`).icon;}
|
|
catch {
|
|
isrc = './assets/icons/base/file.svg';
|
|
im.style.filter = "invert(29%) sepia(72%) saturate(3276%) hue-rotate(296deg) brightness(69%) contrast(97%)";
|
|
}
|
|
}*/
|
|
else {
|
|
//console.log(path.extname(name));
|
|
if (name.includes('.') && fs.existsSync(`./assets/icons/extension/${(path.extname(name).toLowerCase()).slice(1)}.svg`)) {icon = `./assets/icons/extension/${(path.extname(name).toLowerCase()).slice(1)}.svg`;}
|
|
else if (name.includes('.') && Object.keys(icons.file).includes((path.extname(name).toLowerCase()).slice(1))) {icon = `./assets/icons/extension/${icons.file[(path.extname(name).toLowerCase()).slice(1)]}.svg`;}
|
|
else {icon = './assets/icons/base/file.svg';}
|
|
}
|
|
} catch {icon = './assets/icons/base/file.svg';}
|
|
return icon;
|
|
}; |