diff --git a/Goldleaf/include/fs/fs_Explorer.hpp b/Goldleaf/include/fs/fs_Explorer.hpp index 4acb433d..eb3fdb64 100644 --- a/Goldleaf/include/fs/fs_Explorer.hpp +++ b/Goldleaf/include/fs/fs_Explorer.hpp @@ -37,10 +37,11 @@ namespace fs { std::string mnt_name; std::string cwd; bool warn_write; + bool block_write; FileMode started_file_mode; public: - Explorer() : warn_write(false), started_file_mode(FileMode::None) {} + Explorer() : warn_write(false), block_write(false), started_file_mode(FileMode::None) {} virtual ~Explorer() {} void SetNames(const std::string &mount_name, const std::string &display_name); @@ -150,6 +151,14 @@ namespace fs { return this->warn_write; } + inline void SetWriteAccessBlocked(const bool should_warn) { + this->block_write = should_warn; + } + + inline bool IsWriteAccessBlocked() { + return this->block_write; + } + virtual std::vector GetDirectories(const std::string &path) = 0; virtual std::vector GetFiles(const std::string &path) = 0; virtual bool Exists(const std::string &path) = 0; diff --git a/Goldleaf/include/ui/ui_PartitionBrowserLayout.hpp b/Goldleaf/include/ui/ui_PartitionBrowserLayout.hpp index 4766d9c3..9ac1ccb6 100644 --- a/Goldleaf/include/ui/ui_PartitionBrowserLayout.hpp +++ b/Goldleaf/include/ui/ui_PartitionBrowserLayout.hpp @@ -44,7 +44,7 @@ namespace ui { void HandleFileDirectly(const std::string &path); void PromptDeleteFile(const std::string &path); bool GoBack(); - bool WarnWriteAccess(); + bool CheckWriteAccess(); void fsItems_DefaultKey(const std::string &item); void fsItems_Y(const std::string &item); diff --git a/Goldleaf/romfs/Strings/de.json b/Goldleaf/romfs/Strings/de.json index 2d6b4eb4..e9193faa 100644 --- a/Goldleaf/romfs/Strings/de.json +++ b/Goldleaf/romfs/Strings/de.json @@ -474,5 +474,6 @@ "Copying file...", "Copying directory...", "Ignore hidden files/directories", - "Show deletion prompt after NSP installs" + "Show deletion prompt after NSP installs", + "Write access is blocked here..." ] diff --git a/Goldleaf/romfs/Strings/en-US.json b/Goldleaf/romfs/Strings/en-US.json index 3ea27942..5dcccc85 100644 --- a/Goldleaf/romfs/Strings/en-US.json +++ b/Goldleaf/romfs/Strings/en-US.json @@ -474,5 +474,6 @@ "Copying file...", "Copying directory...", "Ignore hidden files/directories", - "Show deletion prompt after NSP installs" + "Show deletion prompt after NSP installs", + "Write access is blocked here..." ] diff --git a/Goldleaf/romfs/Strings/es.json b/Goldleaf/romfs/Strings/es.json index 9e441d3d..3b16bd9d 100644 --- a/Goldleaf/romfs/Strings/es.json +++ b/Goldleaf/romfs/Strings/es.json @@ -474,5 +474,6 @@ "Copiando archivo...", "Copiando carpeta...", "Ignorar archivos/carpetas ocultas", - "Mostrar diálogo de eliminación tras instalar NSPs" + "Mostrar diálogo de eliminación tras instalar NSPs", + "El acceso a escritura está bloqueado aquí..." ] diff --git a/Goldleaf/romfs/Strings/fr.json b/Goldleaf/romfs/Strings/fr.json index 3e44feb8..234be5b5 100644 --- a/Goldleaf/romfs/Strings/fr.json +++ b/Goldleaf/romfs/Strings/fr.json @@ -474,5 +474,6 @@ "Copying file...", "Copying directory...", "Ignore hidden files/directories", - "Show deletion prompt after NSP installs" + "Show deletion prompt after NSP installs", + "Write access is blocked here..." ] diff --git a/Goldleaf/romfs/Strings/it.json b/Goldleaf/romfs/Strings/it.json index b6c6caef..a0e8a5b0 100644 --- a/Goldleaf/romfs/Strings/it.json +++ b/Goldleaf/romfs/Strings/it.json @@ -474,5 +474,6 @@ "Copying file...", "Copying directory...", "Ignore hidden files/directories", - "Show deletion prompt after NSP installs" + "Show deletion prompt after NSP installs", + "Write access is blocked here..." ] diff --git a/Goldleaf/romfs/Strings/ja.json b/Goldleaf/romfs/Strings/ja.json index 8a64760e..f1faf39d 100644 --- a/Goldleaf/romfs/Strings/ja.json +++ b/Goldleaf/romfs/Strings/ja.json @@ -474,5 +474,6 @@ "Copying file...", "Copying directory...", "Ignore hidden files/directories", - "Show deletion prompt after NSP installs" + "Show deletion prompt after NSP installs", + "Write access is blocked here..." ] diff --git a/Goldleaf/romfs/Strings/ko.json b/Goldleaf/romfs/Strings/ko.json index 8b1c5366..7cbd7caa 100644 --- a/Goldleaf/romfs/Strings/ko.json +++ b/Goldleaf/romfs/Strings/ko.json @@ -474,5 +474,6 @@ "파일 복사 중...", "디렉터리 복사 중...", "Ignore hidden files/directories", - "Show deletion prompt after NSP installs" + "Show deletion prompt after NSP installs", + "Write access is blocked here..." ] diff --git a/Goldleaf/romfs/Strings/nl.json b/Goldleaf/romfs/Strings/nl.json index 7307390f..d701af88 100644 --- a/Goldleaf/romfs/Strings/nl.json +++ b/Goldleaf/romfs/Strings/nl.json @@ -474,5 +474,6 @@ "Copying file...", "Copying directory...", "Ignore hidden files/directories", - "Show deletion prompt after NSP installs" + "Show deletion prompt after NSP installs", + "Write access is blocked here..." ] diff --git a/Goldleaf/romfs/Strings/pt.json b/Goldleaf/romfs/Strings/pt.json index 6448d736..c4d1d9c6 100644 --- a/Goldleaf/romfs/Strings/pt.json +++ b/Goldleaf/romfs/Strings/pt.json @@ -474,5 +474,6 @@ "Copying file...", "Copying directory...", "Ignore hidden files/directories", - "Show deletion prompt after NSP installs" + "Show deletion prompt after NSP installs", + "Write access is blocked here..." ] diff --git a/Goldleaf/romfs/Strings/zh-Hans.json b/Goldleaf/romfs/Strings/zh-Hans.json index 4773e39d..1da99dbc 100644 --- a/Goldleaf/romfs/Strings/zh-Hans.json +++ b/Goldleaf/romfs/Strings/zh-Hans.json @@ -474,5 +474,6 @@ "正在复制文件...", "正在复制文件夹...", "Ignore hidden files/directories", - "Show deletion prompt after NSP installs" + "Show deletion prompt after NSP installs", + "Write access is blocked here..." ] diff --git a/Goldleaf/romfs/Strings/zh-Hant.json b/Goldleaf/romfs/Strings/zh-Hant.json index eef84d0f..f9e6eac0 100644 --- a/Goldleaf/romfs/Strings/zh-Hant.json +++ b/Goldleaf/romfs/Strings/zh-Hant.json @@ -474,5 +474,6 @@ "Copying file...", "Copying directory...", "Ignore hidden files/directories", - "Show deletion prompt after NSP installs" + "Show deletion prompt after NSP installs", + "Write access is blocked here..." ] diff --git a/Goldleaf/source/ui/ui_PartitionBrowserLayout.cpp b/Goldleaf/source/ui/ui_PartitionBrowserLayout.cpp index 45967f08..497fa0b9 100644 --- a/Goldleaf/source/ui/ui_PartitionBrowserLayout.cpp +++ b/Goldleaf/source/ui/ui_PartitionBrowserLayout.cpp @@ -189,7 +189,7 @@ namespace ui { } void PartitionBrowserLayout::PromptDeleteFile(const std::string &path) { - if(this->WarnWriteAccess()) { + if(this->CheckWriteAccess()) { const auto option = g_MainApplication->CreateShowDialog(cfg::Strings.GetString(127), cfg::Strings.GetString(128), { cfg::Strings.GetString(111), cfg::Strings.GetString(18) }, true); if(option < 0) { return; @@ -209,12 +209,18 @@ namespace ui { return this->cur_exp->NavigateBack(); } - bool PartitionBrowserLayout::WarnWriteAccess() { - if(!this->cur_exp->ShouldWarnOnWriteAccess()) { + bool PartitionBrowserLayout::CheckWriteAccess() { + if(this->cur_exp->IsWriteAccessBlocked()) { + g_MainApplication->ShowNotification(cfg::Strings.GetString(476)); + return false; + } + else if(this->cur_exp->ShouldWarnOnWriteAccess()) { + const auto option = g_MainApplication->CreateShowDialog(cfg::Strings.GetString(50), cfg::Strings.GetString(51), { cfg::Strings.GetString(111), cfg::Strings.GetString(18) }, true); + return option == 0; + } + else { return true; } - const auto option = g_MainApplication->CreateShowDialog(cfg::Strings.GetString(50), cfg::Strings.GetString(51), { cfg::Strings.GetString(111), cfg::Strings.GetString(18) }, true); - return option == 0; } void PartitionBrowserLayout::fsItems_DefaultKey(const std::string &item) { @@ -373,7 +379,7 @@ namespace ui { const auto rc = romfsMountFromFsdev(full_item.c_str(), romfs_offset, mnt_name.c_str()); if(R_SUCCEEDED(rc)) { auto romfs_exp = new fs::RomFsExplorer("NroRomFs-" + romfs_id, mnt_name, true); - romfs_exp->SetShouldWarnOnWriteAccess(true); + romfs_exp->SetWriteAccessBlocked(true); g_MainApplication->GetExploreMenuLayout()->AddMountedExplorer(romfs_exp, "RomFs (" + fs::GetBaseName(full_item) + ")", g_Settings.PathForResource("/Common/NAND.png")); g_MainApplication->ShowNotification(cfg::Strings.GetString(454)); } @@ -606,19 +612,21 @@ namespace ui { this->PromptDeleteFile(full_item); } else if(option_1 == static_cast(rename_option)) { - const auto new_name = ShowKeyboard(cfg::Strings.GetString(130), item); - if(!new_name.empty()) { - if(new_name == item) { - return; - } - const auto new_path = this->cur_exp->FullPathFor(new_name); - if(this->cur_exp->IsFile(new_path) || this->cur_exp->IsDirectory(new_path)) { - HandleResult(rc::goldleaf::ResultEntryAlreadyPresent, cfg::Strings.GetString(254)); - } - else if(this->WarnWriteAccess()) { - this->cur_exp->RenameFile(full_item, new_path); - g_MainApplication->ShowNotification(cfg::Strings.GetString(133)); - this->UpdateElements(this->browse_menu->GetSelectedIndex()); + if(this->CheckWriteAccess()) { + const auto new_name = ShowKeyboard(cfg::Strings.GetString(130), item); + if(!new_name.empty()) { + if(new_name == item) { + return; + } + const auto new_path = this->cur_exp->FullPathFor(new_name); + if(this->cur_exp->IsFile(new_path) || this->cur_exp->IsDirectory(new_path)) { + HandleResult(rc::goldleaf::ResultEntryAlreadyPresent, cfg::Strings.GetString(254)); + } + else { + this->cur_exp->RenameFile(full_item, new_path); + g_MainApplication->ShowNotification(cfg::Strings.GetString(133)); + this->UpdateElements(this->browse_menu->GetSelectedIndex()); + } } } } @@ -705,7 +713,7 @@ namespace ui { break; } case 2: { - if(this->WarnWriteAccess()) { + if(this->CheckWriteAccess()) { const auto option_2 = g_MainApplication->CreateShowDialog(cfg::Strings.GetString(325), cfg::Strings.GetString(326), { cfg::Strings.GetString(111), cfg::Strings.GetString(18) }, true); if(option_2 < 0) { return; @@ -717,20 +725,22 @@ namespace ui { break; } case 3: { - const auto new_name = ShowKeyboard(cfg::Strings.GetString(238), item); - if(!new_name.empty()) { - if(new_name == item) { - // TODO: special handling? - return; - } - const auto new_path = this->cur_exp->FullPathFor(new_name); - if(this->cur_exp->IsFile(new_path) || this->cur_exp->IsDirectory(new_path)) { - HandleResult(rc::goldleaf::ResultEntryAlreadyPresent, cfg::Strings.GetString(254)); - } - else if(this->WarnWriteAccess()) { - this->cur_exp->RenameDirectory(full_item, new_path); - g_MainApplication->ShowNotification(cfg::Strings.GetString(139)); - this->UpdateElements(); + if(this->CheckWriteAccess()) { + const auto new_name = ShowKeyboard(cfg::Strings.GetString(238), item); + if(!new_name.empty()) { + if(new_name == item) { + // TODO: special handling? + return; + } + const auto new_path = this->cur_exp->FullPathFor(new_name); + if(this->cur_exp->IsFile(new_path) || this->cur_exp->IsDirectory(new_path)) { + HandleResult(rc::goldleaf::ResultEntryAlreadyPresent, cfg::Strings.GetString(254)); + } + else { + this->cur_exp->RenameDirectory(full_item, new_path); + g_MainApplication->ShowNotification(cfg::Strings.GetString(139)); + this->UpdateElements(); + } } } break;