2018-07-17 06:43:35 -05:00
|
|
|
#ifndef OPENMC_FILE_UTILS_H
|
|
|
|
|
#define OPENMC_FILE_UTILS_H
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
namespace openmc {
|
|
|
|
|
|
2025-01-27 23:31:59 -08:00
|
|
|
// NOTE: This is a thin wrapper over std::filesystem because we
|
|
|
|
|
// pass strings around a lot. Objects like settings::path_input
|
|
|
|
|
// are extern std::string to play with other libraries and languages
|
|
|
|
|
|
2022-12-06 14:39:44 -06:00
|
|
|
//! Determine if a path is a directory
|
|
|
|
|
//! \param[in] path Path to check
|
|
|
|
|
//! \return Whether the path is a directory
|
2023-04-15 11:52:36 -04:00
|
|
|
bool dir_exists(const std::string& path);
|
2022-12-06 14:39:44 -06:00
|
|
|
|
2018-08-23 21:38:23 -05:00
|
|
|
//! Determine if a file exists
|
|
|
|
|
//! \param[in] filename Path to file
|
|
|
|
|
//! \return Whether file exists
|
2023-04-15 11:52:36 -04:00
|
|
|
bool file_exists(const std::string& filename);
|
2018-07-17 06:43:35 -05:00
|
|
|
|
2024-01-16 11:12:44 -06:00
|
|
|
//! Determine directory containing given file
|
|
|
|
|
//! \param[in] filename Path to file
|
2025-01-27 23:31:59 -08:00
|
|
|
//! \return Name of directory containing file excluding the final directory
|
|
|
|
|
//! separator
|
2024-01-16 11:12:44 -06:00
|
|
|
std::string dir_name(const std::string& filename);
|
|
|
|
|
|
2023-03-31 13:46:42 -04:00
|
|
|
// Gets the file extension of whatever string is passed in. This is defined as
|
|
|
|
|
// a sequence of strictly alphanumeric characters which follow the last period,
|
|
|
|
|
// i.e. at least one alphabet character is present, and zero or more numbers.
|
|
|
|
|
// If such a sequence of characters is not found, an empty string is returned.
|
2023-04-15 11:52:36 -04:00
|
|
|
std::string get_file_extension(const std::string& filename);
|
2023-03-31 13:46:42 -04:00
|
|
|
|
2018-08-23 21:38:23 -05:00
|
|
|
} // namespace openmc
|
2018-07-17 06:43:35 -05:00
|
|
|
|
2018-08-23 21:38:23 -05:00
|
|
|
#endif // OPENMC_FILE_UTILS_H
|