Skip to content

Commit

Permalink
print env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri Rusin committed Nov 14, 2023
1 parent 3537f84 commit 5855875
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions include/ioh/common/file.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@

#pragma once

#include "ioh/common/format.hpp"
#include "ioh/common/log.hpp"
#include <cstdlib>
#include <filesystem>
#include <iostream>
#include <string>
#include <utility>
#include "ioh/common/log.hpp"
#include "ioh/common/format.hpp"

#ifdef FSEXPERIMENTAL
#define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
Expand All @@ -18,6 +21,8 @@ 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 @@ -98,6 +103,15 @@ namespace ioh::common::file
*
* @return fs::path the absolute path of IOHexperimenter/static
*/
inline void print_environment_variables()
{
for (char** env = environ; *env != nullptr; ++env)
{
std::cout << *env << std::endl;
std::cerr << *env << std::endl;
}
}

inline fs::path get_static_root()
{
const char* env_var = std::getenv("IOH_RESOURCES");
Expand All @@ -107,6 +121,9 @@ namespace ioh::common::file
print_directory_contents(fs::current_path() / "..");
print_directory_contents(fs::current_path() / ".." / "..");

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

if (env_var == nullptr)
{
return fs::canonical(fs::current_path() / ".." / ".." / "static");
Expand Down

0 comments on commit 5855875

Please sign in to comment.