StatMech
Loading...
Searching...
No Matches
file_util.hpp File Reference

Go to the source code of this file.

Functions

bool checkFileExistence (std::string const &str)
 
bool checkIsFileOpen (std::ifstream &file, std::string const &filename)
 
bool checkIsFileOpen (std::ofstream &file, std::string const &filename)
 

Function Documentation

◆ checkFileExistence()

bool checkFileExistence ( std::string const &  str)
16 {
17 std::ifstream ifs(str);
18 return ifs.is_open();
19}

◆ checkIsFileOpen() [1/2]

bool checkIsFileOpen ( std::ifstream &  file,
std::string const &  filename 
)
22 {
23 if( file.fail() ) {
24 std::cerr << "Can't open a file " << filename << "." << std::endl;
25 std::exit(EX_CANTCREAT);
26 }
27 return true;
28}

◆ checkIsFileOpen() [2/2]

bool checkIsFileOpen ( std::ofstream &  file,
std::string const &  filename 
)
29 {
30 if( file.fail() ) {
31 std::cerr << "Can't open a file " << filename << "." << std::endl;
32 std::exit(EX_CANTCREAT);
33 }
34 return true;
35}