@@ -1291,7 +1291,8 @@ namespace vix::commands
12911291 dep.tag = v.at (" tag" ).get <std::string>();
12921292 dep.commit = v.at (" commit" ).get <std::string>();
12931293 dep.type = entry.value (" type" , " header-only" );
1294- if (v.contains (" extensions" ) && v[" extensions" ].is_object ()) dep.extensions = v[" extensions" ];
1294+ if (v.contains (" extensions" ) && v[" extensions" ].is_object ())
1295+ dep.extensions = v[" extensions" ];
12951296 dep.checkout = store_checkout_path (dep.id , dep.commit );
12961297
12971298 return dep;
@@ -1361,8 +1362,10 @@ namespace vix::commands
13611362 item[" files" ] = make_files_json (files);
13621363 item[" executables" ] = make_strings_json (executables);
13631364 item[" shims" ] = make_strings_json (shims);
1364- if (!dep.extensions .is_null ()) item[" extensions" ] = dep.extensions ;
1365- else item.erase (" extensions" );
1365+ if (!dep.extensions .is_null ())
1366+ item[" extensions" ] = dep.extensions ;
1367+ else
1368+ item.erase (" extensions" );
13661369 updated = true ;
13671370 break ;
13681371 }
@@ -1389,7 +1392,8 @@ namespace vix::commands
13891392 {" executables" , make_strings_json (executables)},
13901393 {" shims" , make_strings_json (shims)},
13911394 };
1392- if (!dep.extensions .is_null ()) newItem[" extensions" ] = dep.extensions ;
1395+ if (!dep.extensions .is_null ())
1396+ newItem[" extensions" ] = dep.extensions ;
13931397 arr.push_back (std::move (newItem));
13941398 }
13951399
@@ -2395,24 +2399,43 @@ namespace vix::commands
23952399 static std::vector<fs::path> collect_regular_files (const fs::path &root)
23962400 {
23972401 std::vector<fs::path> files;
2402+
23982403 std::error_code ec;
2399- if (!fs::exists (root, ec))
2404+ if (!fs::exists (root, ec) || ec )
24002405 return files;
24012406
2402- for (fs::recursive_directory_iterator it (root, fs::directory_options::skip_permission_denied, ec), end;
2403- !ec && it != end;
2404- it.increment (ec))
2405- {
2406- if (ec)
2407- break ;
2407+ fs::recursive_directory_iterator it (
2408+ root,
2409+ fs::directory_options::skip_permission_denied,
2410+ ec);
2411+ const fs::recursive_directory_iterator end;
24082412
2413+ if (ec)
2414+ return files;
2415+
2416+ while (it != end)
2417+ {
24092418 const fs::path p = it->path ();
2410- const auto st = fs::symlink_status (p, ec);
2411- if (ec)
2412- continue ;
24132419
2414- if (fs::is_regular_file (st) || fs::is_symlink (st))
2415- files.push_back (fs::relative (p, root).lexically_normal ());
2420+ std::error_code entryEc;
2421+ const auto status = fs::symlink_status (p, entryEc);
2422+
2423+ if (!entryEc &&
2424+ (fs::is_regular_file (status) || fs::is_symlink (status)))
2425+ {
2426+ std::error_code relativeEc;
2427+ const fs::path relative = fs::relative (p, root, relativeEc);
2428+
2429+ if (!relativeEc)
2430+ files.push_back (relative.lexically_normal ());
2431+ }
2432+
2433+ it.increment (ec);
2434+ if (ec)
2435+ {
2436+ ec.clear ();
2437+ break ;
2438+ }
24162439 }
24172440
24182441 std::sort (files.begin (), files.end ());
@@ -2427,17 +2450,36 @@ namespace vix::commands
24272450 if (!fs::exists (bin, ec) || !fs::is_directory (bin, ec))
24282451 return commands;
24292452
2430- for (fs::directory_iterator it (bin, ec), end; !ec && it != end; it.increment (ec))
2453+ fs::directory_iterator it (bin, ec);
2454+ const fs::directory_iterator end;
2455+
2456+ if (ec)
2457+ return commands;
2458+
2459+ while (it != end)
24312460 {
2461+ std::error_code entryEc;
2462+ const fs::file_status status = it->symlink_status (entryEc);
2463+
2464+ if (!entryEc &&
2465+ (fs::is_regular_file (status) || fs::is_symlink (status)) &&
2466+ is_executable_filename (it->path ()))
2467+ {
2468+ const std::string cmd = executable_command_name (it->path ());
2469+
2470+ if (!cmd.empty () &&
2471+ std::find (commands.begin (), commands.end (), cmd) == commands.end ())
2472+ {
2473+ commands.push_back (cmd);
2474+ }
2475+ }
2476+
2477+ it.increment (ec);
24322478 if (ec)
2479+ {
2480+ ec.clear ();
24332481 break ;
2434- if (!it->is_regular_file (ec) && !it->is_symlink (ec))
2435- continue ;
2436- if (!is_executable_filename (it->path ()))
2437- continue ;
2438- const std::string cmd = executable_command_name (it->path ());
2439- if (!cmd.empty () && std::find (commands.begin (), commands.end (), cmd) == commands.end ())
2440- commands.push_back (cmd);
2482+ }
24412483 }
24422484
24432485 std::sort (commands.begin (), commands.end ());
0 commit comments