IO: don't try to load a directory in Filesystem::open

master
Martin Gerhardy 2022-04-23 21:29:56 +02:00
parent 1d45aba0e5
commit 92fc77e8b6
2 changed files with 4 additions and 1 deletions

View File

@ -87,7 +87,7 @@ ImagePtr loadImage(const core::String& filename, bool async) {
}
}
}
if (!file) {
if (!file->validHandle()) {
return createEmptyImage(filename);
}
return loadImage(file, async);

View File

@ -416,6 +416,9 @@ bool Filesystem::pushDir(const core::String &directory) {
}
io::FilePtr Filesystem::open(const core::String &filename, FileMode mode) const {
if (isReadableDir(filename)) {
return core::make_shared<io::File>("", mode);
}
if (mode == FileMode::SysWrite) {
Log::debug("Use absolute path to open file %s for writing", filename.c_str());
return core::make_shared<io::File>(filename, mode);