Skip to content

Commit 47b2a4c

Browse files
committed
Update View.cpp
1 parent 6521292 commit 47b2a4c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Tactility/Source/app/files/View.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,15 +415,16 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
415415
auto filename = inputdialog::getResult(*bundle);
416416
if (!filename.empty()) {
417417
std::string new_file_path = file::getChildPath(state->getCurrentPath(), filename);
418+
419+
auto lock = file::getLock(new_file_path);
420+
lock->lock();
421+
418422
struct stat st;
419423
if (stat(new_file_path.c_str(), &st) == 0) {
420424
TT_LOG_W(TAG, "File already exists: \"%s\"", new_file_path.c_str());
421425
break;
422426
}
423427

424-
auto lock = file::getLock(new_file_path);
425-
lock->lock();
426-
427428
FILE* new_file = fopen(new_file_path.c_str(), "w");
428429
if (new_file) {
429430
fclose(new_file);
@@ -442,8 +443,16 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
442443
auto foldername = inputdialog::getResult(*bundle);
443444
if (!foldername.empty()) {
444445
std::string new_folder_path = file::getChildPath(state->getCurrentPath(), foldername);
446+
445447
auto lock = file::getLock(new_folder_path);
446448
lock->lock();
449+
450+
struct stat st;
451+
if (stat(new_folder_path.c_str(), &st) == 0) {
452+
TT_LOG_W(TAG, "Folder already exists: \"%s\"", new_folder_path.c_str());
453+
break;
454+
}
455+
447456
if (mkdir(new_folder_path.c_str(), 0755) == 0) {
448457
TT_LOG_I(TAG, "Created folder \"%s\"", new_folder_path.c_str());
449458
} else {

0 commit comments

Comments
 (0)