Skip to content

Commit 75d487e

Browse files
committed
fix raster root only checking <year> and default subfolders
1 parent 3c48412 commit 75d487e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/cpp/fs/Util.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,16 @@ FileList read_directory(const string_view name, const string_view match, const b
101101
}
102102
FileList find_rasters(const string_view dir, const YearSize year)
103103
{
104-
const auto for_year = string(dir) + "/" + to_string(year) + "/";
105-
const auto for_default = string(dir) + "/default/";
104+
// HACK: read_directory() doesn't work if path doesn't end in '/'
105+
const string path = string(dir) + (dir.ends_with("/") ? "" : "/");
106+
const string for_year = path + to_string(year) + "/";
107+
const string for_default = path + "default/";
106108
// use first existing folder of dir/year, dir/default, or dir in that order
107-
const auto raster_root = directory_exists(for_year.c_str())
108-
? for_year
109-
: (directory_exists(for_default.c_str()) ? for_default : dir);
109+
const string raster_root = directory_exists(for_year.c_str())
110+
? for_year
111+
: (directory_exists(for_default.c_str()) ? for_default : path);
110112
FileList files{};
113+
logging::info("Raster root is %s", raster_root.c_str());
111114
try
112115
{
113116
files.append_range(read_directory(raster_root, "fuel.*\\.tif"));

0 commit comments

Comments
 (0)