diff --git a/Code/IO/otbTileMapImageIO.cxx b/Code/IO/otbTileMapImageIO.cxx index e36633098c29cca72ff233099aafa808fe655416..2be31976921ac925a6f3f19e5a00a951956e6643 100644 --- a/Code/IO/otbTileMapImageIO.cxx +++ b/Code/IO/otbTileMapImageIO.cxx @@ -221,6 +221,13 @@ void TileMapImageIO::GenerateTileInfo(double x, double y, int numTileX, int numT */ bool TileMapImageIO::CanReadFromCache(std::string filename) { + // Verify that the file exists and is not a directory + bool fileExists = itksys::SystemTools::FileExists(filename.c_str(), true); + if (!fileExists) + { + return false; + } + itk::ImageIOBase::Pointer imageIO; imageIO = otb::GDALImageIO::New(); return imageIO->CanReadFile(filename.c_str());