Skip to content

Commit

Permalink
add command to print directory contents for debugging GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri Rusin committed Nov 14, 2023
1 parent 683f170 commit 3537f84
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion include/ioh/common/file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,25 @@ namespace ioh::common::file
operator std::string() const { return data; }
};

inline void print_directory_contents(const fs::path& dir_path)
{
try
{
if (fs::exists(dir_path) && fs::is_directory(dir_path))
{
for (const auto& entry : fs::directory_iterator(dir_path))
{
std::cout << entry.path() << std::endl;
std::cerr << entry.path() << std::endl;
}
}
}
catch (const fs::filesystem_error& e)
{
std::cerr << "Filesystem error: " << e.what() << std::endl;
}
}

/**
* @brief Get the absolute path of IOHexperimenter/static
*
Expand All @@ -82,6 +101,12 @@ namespace ioh::common::file
inline fs::path get_static_root()
{
const char* env_var = std::getenv("IOH_RESOURCES");

// Print the contents of the current, previous, and the one before previous directories
print_directory_contents(fs::current_path());
print_directory_contents(fs::current_path() / "..");
print_directory_contents(fs::current_path() / ".." / "..");

if (env_var == nullptr)
{
return fs::canonical(fs::current_path() / ".." / ".." / "static");
Expand All @@ -90,7 +115,6 @@ namespace ioh::common::file
return fs::canonical(env_var);
}


/**
* @brief Finds a file located in the static folder of this repository
*
Expand Down

0 comments on commit 3537f84

Please sign in to comment.