From 61961973cfd10853b32c7f904cdb88f9ab6d84dd Mon Sep 17 00:00:00 2001 From: 2e0byo <2e0byo@gmail.com> Date: Wed, 15 Mar 2023 15:19:16 +0000 Subject: [PATCH] feat: be case-insensitive about suffixes. (#44) Unfortunately many cameras/mobiles still use ALL_CAPS. --- src/render/WallpaperTarget.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/render/WallpaperTarget.cpp b/src/render/WallpaperTarget.cpp index 9751e1f..37a4cf5 100644 --- a/src/render/WallpaperTarget.cpp +++ b/src/render/WallpaperTarget.cpp @@ -10,9 +10,10 @@ void CWallpaperTarget::create(const std::string& path) { const auto BEGINLOAD = std::chrono::system_clock::now(); cairo_surface_t* CAIROSURFACE = nullptr; - if (path.find(".png") == path.length() - 4) { + const auto len = path.length(); + if (path.find(".png") == len - 4 || path.find(".PNG") == len - 4) { CAIROSURFACE = cairo_image_surface_create_from_png(path.c_str()); - } else if (path.find(".jpg") == path.length() - 4 || path.find(".jpeg") == path.length() - 5) { + } else if (path.find(".jpg") == len - 4 || path.find(".JPG") == len - 4 || path.find(".jpeg") == len - 5 || path.find(".JPEG") == len - 5) { CAIROSURFACE = JPEG::createSurfaceFromJPEG(path); m_bHasAlpha = false; } else {