Refactor file management functions.
This commit is contained in:
parent
7ddca00871
commit
3a6d3bb8c2
@ -53,26 +53,26 @@ function isRoot(): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getImages(): void {
|
function getImages(): void {
|
||||||
// const cwd = process.cwd();
|
const cwd = process.cwd();
|
||||||
// fs.readdir('.', { withFileTypes: true }, ((err, files) => {
|
fs.readdir('.', { withFileTypes: true }, ((err, files) => {
|
||||||
// if (!err) {
|
if (!err) {
|
||||||
// const re = /(?:\.([^.]+))?$/;
|
const re = /(?:\.([^.]+))?$/;
|
||||||
// const images = files.filter(file => file.isFile() && ['jpg', 'png'].includes(re.exec(file.name)[1])).map(file => `file://${cwd}/${file.name}`);
|
const images = files.filter(file => file.isFile() && ['jpg', 'png'].includes(re.exec(file.name)[1])).map(file => `file://${cwd}/${file.name}`);
|
||||||
// mainWindow.webContents.send('getImagesResponse', images);
|
mainWindow.webContents.send('getImagesResponse', images);
|
||||||
// }
|
}
|
||||||
// }));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDirectory(): void {
|
function getDirectory(): void {
|
||||||
// fs.readdir('.', { withFileTypes: true }, (err, files) => {
|
fs.readdir('.', { withFileTypes: true }, (err, files) => {
|
||||||
// if (!err) {
|
if (!err) {
|
||||||
// const directories = files.filter(file => file.isDirectory()).map(file => file.name);
|
const directories = files.filter(file => file.isDirectory()).map(file => file.name);
|
||||||
// if (!isRoot()) {
|
if (!isRoot()) {
|
||||||
// directories.unshift('..');
|
directories.unshift('..');
|
||||||
// }
|
}
|
||||||
// mainWindow.webContents.send('getDirectoryResponse', directories);
|
mainWindow.webContents.send('getDirectoryResponse', directories);
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
|
Loading…
Reference in New Issue
Block a user