Check mount location

This commit is contained in:
Scott E. Graves
2018-12-12 10:28:04 -06:00
parent eb5198d601
commit e223eac541
4 changed files with 69 additions and 26 deletions

View File

@@ -261,6 +261,29 @@ ipcMain.on(Constants.IPC_Check_Installed, (event, data) => {
});
});
ipcMain.on(Constants.IPC_Check_Mount_Location, (event, data) => {
let response = {
Success: true,
Error: ''
};
try {
if (fs.existsSync(data.Location) && fs.statSync(data.Location).isDirectory()) {
if (fs.readdirSync(data.Location).length !== 0) {
response.Success = false;
response.Error = 'Directory not empty: ' + data.Location;
}
} else {
response.Success = false;
response.Error = 'Directory not found: ' + data.Location;
}
} catch (e) {
response.Success = false;
response.Error = e.toString();
}
event.returnValue = response;
});
ipcMain.on(Constants.IPC_Delete_File, (event, data) => {
try {
if (fs.existsSync(data.FilePath)) {