mirror of
https://github.com/hyprwm/hyprgraphics.git
synced 2026-05-08 04:18:09 +02:00
feat: add isImageFile() static utility method
Adds a static isImageFile() method to CImage that validates if a file path points to a loadable image by attempting to load it. Returns true only if the image loads successfully. Memory is freed immediately after the check via scope block.
This commit is contained in:
parent
f114ea3d97
commit
52aa6ef829
2 changed files with 11 additions and 0 deletions
|
|
@ -37,6 +37,8 @@ namespace Hyprgraphics {
|
|||
|
||||
Hyprutils::Memory::CSharedPointer<CCairoSurface> cairoSurface();
|
||||
|
||||
static bool isImageFile(const std::string& path);
|
||||
|
||||
private:
|
||||
std::string lastError, filepath, mime;
|
||||
Hyprutils::Math::Vector2D m_svgSize;
|
||||
|
|
|
|||
|
|
@ -123,3 +123,12 @@ Hyprutils::Memory::CSharedPointer<CCairoSurface> Hyprgraphics::CImage::cairoSurf
|
|||
std::string Hyprgraphics::CImage::getMime() {
|
||||
return mime;
|
||||
}
|
||||
|
||||
bool Hyprgraphics::CImage::isImageFile(const std::string& path) {
|
||||
bool result;
|
||||
{
|
||||
CImage test(path);
|
||||
result = test.success();
|
||||
} // test destroyed here, memory freed
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue