Skip to content

Commit

Permalink
Check for dir existence
Browse files Browse the repository at this point in the history
  • Loading branch information
DariaKunoichi committed Dec 16, 2024
1 parent 1ff7f5b commit 4a46c4d
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,20 @@ void ls(String path, Promise promise) {
void mkdir(String path, Promise promise) {
Log.w(TAG, "mkdir start " + path);
try {
boolean result = new File(path).mkdirs();
File file = new File(path);
if (file.exists()) {
Log.w(TAG, "mkdir already exists " + path);
promise.reject(new Exception("EEXIST", path + " already exists."));
return;
}

boolean result = file.mkdirs();
if (result) {
Log.w(TAG, "mkdir true " + path);
promise.resolve(path);
} else {
Log.w(TAG, "mkdir false " + path);
promise.reject(new Exception("Failed to create directory"));
promise.reject(new Exception("EPERM", "Failed to create directory " + path));
}
} catch(Exception e) {
Log.w(TAG, "mkdir exception " + e.toString());
Expand Down

0 comments on commit 4a46c4d

Please sign in to comment.