Skip to content

Commit

Permalink
Do not print paths in the current directory of env var keys or values.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri Rusin committed Nov 15, 2023
1 parent 88bd25b commit ea28a78
Showing 1 changed file with 0 additions and 40 deletions.
40 changes: 0 additions & 40 deletions include/ioh/common/file.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#pragma once

#include "ioh/common/format.hpp"
Expand All @@ -19,8 +18,6 @@ namespace fs = std::experimental::filesystem;
namespace fs = std::filesystem;
#endif

extern char** environ; // Declaration for the environment variables

#ifdef HAS_JSON
#include <nlohmann/json.hpp>
using json = nlohmann::json;
Expand Down Expand Up @@ -77,50 +74,13 @@ 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;
}
}


inline void print_environment_variables()
{
for (char** env = environ; *env != nullptr; ++env)
{
std::cout << *env << std::endl;
std::cerr << *env << std::endl;
}
}

/**
* @brief Get the absolute path of IOHexperimenter/static
*
* @return fs::path the absolute path of IOHexperimenter/static
*/
inline fs::path get_static_root()
{
// 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() / ".." / "..");

// Print environment variables to stdout and stderr
print_environment_variables();

const char* github_workspace = std::getenv("GITHUB_WORKSPACE");
if (github_workspace != nullptr)
{
Expand Down

0 comments on commit ea28a78

Please sign in to comment.