Skip to content

Commit 01a50ca

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

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/cpp/fs/Util.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,17 @@ 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 = dir.ends_with("/") ? dir : dir + "/";
106+
const string for_year = path + to_string(year) + "/";
107+
const string for_default = path + "default/";
108+
106109
// 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())
110+
const string raster_root = directory_exists(for_year.c_str())
108111
? for_year
109-
: (directory_exists(for_default.c_str()) ? for_default : dir);
112+
: (directory_exists(for_default.c_str()) ? for_default : path);
110113
FileList files{};
114+
logging::info("Raster root is %s", raster_root.c_str());
111115
try
112116
{
113117
files.append_range(read_directory(raster_root, "fuel.*\\.tif"));

0 commit comments

Comments
 (0)