From e4b3f45d7615b3958a9fac44a9aaa67884f07480 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 6 Dec 2025 21:30:42 +0100 Subject: [PATCH 1/2] cellScreenshot: update filenames --- rpcs3/Emu/Cell/Modules/cellScreenshot.cpp | 20 ++++++++------------ rpcs3/Emu/Cell/Modules/cellScreenshot.h | 2 +- rpcs3/rpcs3qt/gs_frame.cpp | 4 +++- rpcs3/rpcs3qt/qt_utils.cpp | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellScreenshot.cpp b/rpcs3/Emu/Cell/Modules/cellScreenshot.cpp index b899155dde..5d8e2f2a18 100644 --- a/rpcs3/Emu/Cell/Modules/cellScreenshot.cpp +++ b/rpcs3/Emu/Cell/Modules/cellScreenshot.cpp @@ -33,18 +33,12 @@ std::string screenshot_info::get_overlay_path() const std::string screenshot_info::get_photo_title() const { - std::string photo = photo_title; - if (photo.empty()) - photo = Emu.GetTitle(); - return photo; + return photo_title.empty() ? Emu.GetTitle() : photo_title; } std::string screenshot_info::get_game_title() const { - std::string game = game_title; - if (game.empty()) - game = Emu.GetTitle(); - return game; + return game_title.empty() ? Emu.GetTitle() : game_title; } std::string screenshot_info::get_game_comment() const @@ -52,15 +46,17 @@ std::string screenshot_info::get_game_comment() const return game_comment; } -std::string screenshot_info::get_screenshot_path(const std::string& date_path) const +std::string screenshot_info::get_screenshot_path(s32 year, s32 month, s32 day, s32 hour, s32 minute, s32 second) const { u32 counter = 0; - std::string path = vfs::get("/dev_hdd0/photo/" + date_path + "/" + get_photo_title()); - std::string suffix = ".png"; + const std::string path = vfs::get(fmt::format("/dev_hdd0/photo/%04d/%02d/%02d/%s %02d-%02d-%04d %02d-%02d-%02d", + year, month, day, get_photo_title(), day, month, year, hour, minute, second)); + constexpr std::string_view extension = ".png"; + std::string suffix = std::string(extension); while (!Emu.IsStopped() && fs::is_file(path + suffix)) { - suffix = fmt::format("_%d.png", ++counter); + suffix = fmt::format(" %d%s", ++counter, extension); } return path + suffix; diff --git a/rpcs3/Emu/Cell/Modules/cellScreenshot.h b/rpcs3/Emu/Cell/Modules/cellScreenshot.h index 20a8d41cc5..de84257c7b 100644 --- a/rpcs3/Emu/Cell/Modules/cellScreenshot.h +++ b/rpcs3/Emu/Cell/Modules/cellScreenshot.h @@ -44,7 +44,7 @@ struct screenshot_info std::string get_photo_title() const; std::string get_game_title() const; std::string get_game_comment() const; - std::string get_screenshot_path(const std::string& date_path) const; + std::string get_screenshot_path(s32 year, s32 month, s32 day, s32 hour, s32 minute, s32 second) const; }; struct screenshot_manager : public screenshot_info diff --git a/rpcs3/rpcs3qt/gs_frame.cpp b/rpcs3/rpcs3qt/gs_frame.cpp index df6aac317a..a2f122ecbb 100644 --- a/rpcs3/rpcs3qt/gs_frame.cpp +++ b/rpcs3/rpcs3qt/gs_frame.cpp @@ -1040,7 +1040,9 @@ void gs_frame::take_screenshot(std::vector&& data, u32 sshot_width, u32 ssho } } - const std::string cell_sshot_filename = manager.get_screenshot_path(date_time.toString("yyyy/MM/dd").toStdString()); + const QDate date = date_time.date(); + const QTime time = date_time.time(); + const std::string cell_sshot_filename = manager.get_screenshot_path(date.year(), date.month(), date.day(), time.hour(), time.minute(), time.second()); const std::string cell_sshot_dir = fs::get_parent_dir(cell_sshot_filename); screenshot_log.notice("Saving cell screenshot to %s", cell_sshot_filename); diff --git a/rpcs3/rpcs3qt/qt_utils.cpp b/rpcs3/rpcs3qt/qt_utils.cpp index fa5e3c250e..fc53dc542a 100644 --- a/rpcs3/rpcs3qt/qt_utils.cpp +++ b/rpcs3/rpcs3qt/qt_utils.cpp @@ -641,7 +641,7 @@ namespace gui usz byte_unit = 0; usz divisor = 1; #if defined(__APPLE__) - constexpr usz multiplier = 1000; + constexpr usz multiplier = 1000; static const QString s_units[]{"B", "kB", "MB", "GB", "TB", "PB"}; #else constexpr usz multiplier = 1024; From 67b61e8feff3024036f2b823c212bc7bcc0b3db9 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 7 Dec 2025 10:36:55 +0100 Subject: [PATCH 2/2] cellScreenshot: escape photo_title in path --- rpcs3/Emu/Cell/Modules/cellScreenshot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpcs3/Emu/Cell/Modules/cellScreenshot.cpp b/rpcs3/Emu/Cell/Modules/cellScreenshot.cpp index 5d8e2f2a18..baf9ee380d 100644 --- a/rpcs3/Emu/Cell/Modules/cellScreenshot.cpp +++ b/rpcs3/Emu/Cell/Modules/cellScreenshot.cpp @@ -50,7 +50,7 @@ std::string screenshot_info::get_screenshot_path(s32 year, s32 month, s32 day, s { u32 counter = 0; const std::string path = vfs::get(fmt::format("/dev_hdd0/photo/%04d/%02d/%02d/%s %02d-%02d-%04d %02d-%02d-%02d", - year, month, day, get_photo_title(), day, month, year, hour, minute, second)); + year, month, day, vfs::escape(get_photo_title(), true), day, month, year, hour, minute, second)); constexpr std::string_view extension = ".png"; std::string suffix = std::string(extension);