@@ -55,31 +55,38 @@ static std::string format(const char *format, const tsl::ordered_map<std::string
5555}
5656
5757static std::vector<std::string> expand_cmake_path (const fs::path &name, const fs::path &toml_dir, bool is_root_project) {
58- std::vector<std::string> temp;
5958
60- auto extract_suffix = [](const fs::path &base, const fs::path &full) {
59+ auto const extract_suffix = [](const fs::path &base, const fs::path &full) {
6160 auto fullpath = full.string ();
6261 auto base_len = base.string ().length ();
63- auto delet = fullpath.substr (base_len + 1 , fullpath.length () - base_len);
64- return delet;
62+ return fullpath.substr (base_len + 1 , fullpath.length () - base_len);
6563 };
66-
67- auto stem = name.filename ().stem ().string ();
68- auto ext = name.extension ();
64+ auto const extract_path_parts = [](const fs::path &file_path) -> std::pair<std::string, std::string> {
65+ const auto path_as_string = file_path.string ();
66+ auto const dot_position = path_as_string.find (' .' );
67+ if (dot_position != std::string::npos) {
68+ return {path_as_string.substr (0 , dot_position), path_as_string.substr (dot_position)};
69+ }
70+ return {path_as_string, {}};
71+ };
72+ auto const path_parts = extract_path_parts (name.filename ());
73+ auto const &stem = path_parts.first ;
74+ auto const &extension = path_parts.second ;
6975
7076 if (is_root_project && stem == " **" && name == name.filename ()) {
7177 throw std::runtime_error (" Recursive globbing not allowed in project root: " + name.string ());
7278 }
7379
80+ std::vector<std::string> temp;
7481 if (stem == " *" ) {
7582 for (const auto &f : fs::directory_iterator (toml_dir / name.parent_path (), fs::directory_options::follow_directory_symlink)) {
76- if (!f.is_directory () && f.path ().extension () == ext ) {
83+ if (!f.is_directory () && extract_path_parts ( f.path ().filename ()). second == extension ) {
7784 temp.push_back (extract_suffix (toml_dir, f));
7885 }
7986 }
8087 } else if (stem == " **" ) {
8188 for (const auto &f : fs::recursive_directory_iterator (toml_dir / name.parent_path (), fs::directory_options::follow_directory_symlink)) {
82- if (!f.is_directory () && f.path ().extension () == ext ) {
89+ if (!f.is_directory () && extract_path_parts ( f.path ().filename ()). second == extension ) {
8390 temp.push_back (extract_suffix (toml_dir, f.path ()));
8491 }
8592 }
0 commit comments