feat: be case-insensitive about suffixes. (#44)

Unfortunately many cameras/mobiles still use ALL_CAPS.
This commit is contained in:
2e0byo 2023-03-15 15:19:16 +00:00 committed by GitHub
parent 83867464c5
commit 61961973cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -10,9 +10,10 @@ void CWallpaperTarget::create(const std::string& path) {
const auto BEGINLOAD = std::chrono::system_clock::now(); const auto BEGINLOAD = std::chrono::system_clock::now();
cairo_surface_t* CAIROSURFACE = nullptr; 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()); 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); CAIROSURFACE = JPEG::createSurfaceFromJPEG(path);
m_bHasAlpha = false; m_bHasAlpha = false;
} else { } else {