13#ifndef FILES_READ_AND_WRITE_PATHSANDFILES_HPP
14#define FILES_READ_AND_WRITE_PATHSANDFILES_HPP
18#include <boost/filesystem.hpp>
19#include "VCluster/VCluster.hpp"
28 cwd = getcwd(cwd, size);
47 boost::filesystem::path pathObj(path);
48 if (boost::filesystem::exists(pathObj) && boost::filesystem::is_regular_file(pathObj))
55 catch (boost::filesystem::filesystem_error & e)
57 std::cerr << e.what() << std::endl;
68 auto & v_cl = create_vcluster();
73 std::ofstream outfile (path);
90 boost::filesystem::path pathObj(path);
91 if (boost::filesystem::exists(pathObj) && boost::filesystem::is_directory(pathObj))
return true;
93 catch (boost::filesystem::filesystem_error & e)
95 std::cerr << e.what() << std::endl;
105 auto & v_cl = create_vcluster();
106 if (v_cl.rank() == 0)
110 boost::filesystem::create_directory(path);
115 std::cout <<
"Folder for current settings ( '" << path <<
"' ) already exists. New files will be saved to this folder." << std::endl;
static bool check_if_directory_exists(std::string path)
Checks if a directory already exists.
static bool check_if_file_exists(std::string path)
Checks if a file already exists.
static void create_file_if_not_exist(std::string path)
Creates a file if not already existent.
static void create_directory_if_not_exist(std::string path, bool silent=0)
Creates a directory if not already existent.
static std::string get_cwd()
Gets the current working directory and returns path as string.