Skip to content

Commit 2660b68

Browse files
authored
feat: return nil if image file doesn't exist (#19)
1 parent 4bad63f commit 2660b68

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Plugin.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ void on_ref_lua_state_created(lua_State* l) try {
8787
auto image_path = images_path / filepath;
8888

8989
std::filesystem::create_directories(images_path);
90+
if (!std::filesystem::is_regular_file(image_path)) {
91+
return std::shared_ptr<D2DImage>{nullptr};
92+
}
9093

9194
return std::make_shared<D2DImage>(g_plugin->d2d->wic(), g_plugin->d2d->context(), image_path);
9295
},

0 commit comments

Comments
 (0)