From ef5abac1d3778309eb0148ced54e45c69f2d3355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 22 Apr 2023 00:05:07 +0200 Subject: [PATCH] Fix an oversight when saving replacement textures on scoped storage We ended up not properly mangling the filename when changing extensions if the file URI is an Android content URI. Fixes #17320 --- Common/File/Path.cpp | 5 +++++ GPU/Common/TextureReplacer.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Common/File/Path.cpp b/Common/File/Path.cpp index 71a795d683..815593016a 100644 --- a/Common/File/Path.cpp +++ b/Common/File/Path.cpp @@ -131,6 +131,11 @@ Path Path::WithReplacedExtension(const std::string &oldExtension, const std::str } Path Path::WithReplacedExtension(const std::string &newExtension) const { + if (type_ == PathType::CONTENT_URI) { + AndroidContentURI uri(path_); + return Path(uri.WithReplacedExtension(newExtension).ToString()); + } + _dbg_assert_(!newExtension.empty() && newExtension[0] == '.'); if (path_.empty()) { return Path(*this); diff --git a/GPU/Common/TextureReplacer.cpp b/GPU/Common/TextureReplacer.cpp index 8704935178..d133105cc6 100644 --- a/GPU/Common/TextureReplacer.cpp +++ b/GPU/Common/TextureReplacer.cpp @@ -561,7 +561,7 @@ ReplacedTexture *TextureReplacer::FindReplacement(u64 cachekey, u32 hash, int w, static bool WriteTextureToPNG(png_imagep image, const Path &filename, int convert_to_8bit, const void *buffer, png_int_32 row_stride, const void *colormap) { FILE *fp = File::OpenCFile(filename, "wb"); if (!fp) { - ERROR_LOG(IO, "Unable to open texture file for writing."); + ERROR_LOG(IO, "Unable to open texture file '%s' for writing.", filename.c_str()); return false; }