1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-16 19:46:19 +02:00

Misc fixes for file explorer.

- Add validation while dropping a file
- Refactor removing file to work on path not reference
- style fixes
This commit is contained in:
Kushagra Gour
2018-10-12 23:53:36 +05:30
parent d3f06ac890
commit 57e41b2f4d
4 changed files with 36 additions and 19 deletions

View File

@@ -85,3 +85,13 @@ export function removeFileAtPath(files, path) {
const { index } = getChildFileFromName(currentFolder, pathPieces[0]);
currentFolder.splice(index, 1);
}
/**
* Checks if a file with same name exists in the passed folder.
* @param {object} folder Folder to search in
* @param {string} fileName File name to search for
*/
export function doesFileExistInFolder(folder, fileName) {
const details = getChildFileFromName(folder.children, fileName);
return !!details.file;
}