8#include "commonflags.h"
10#define COLOR_R std::string("\033[31m")
11#define COLOR_G std::string("\033[32m")
12#define COLOR_B std::string("\033[34m")
13#define COLOR_Y std::string("\033[33m")
14#define COLOR_E std::string("\033[0m")
17#define FMT(X) " " << std::setiosflags(std::ios::scientific) << std::setprecision(X) << std::setw(FMT_WIDTH_SIZE(X))
21inline int removeFile(std::string& filename) {
return remove(filename.c_str()); }
23inline void clearFile(std::string& filename) { std::ofstream clear(filename, std::ios::trunc); }
26 if (ofs.is_open()) ofs.close();
29inline bool isFileExists(
const std::string& name) {
return std::ifstream{name.c_str()}.good(); }
38 std::string::size_type ipos = s.find_last_of(
DELIM_SEP);
39 return s.substr(0, ipos);
43 std::string::size_type ipos = s.find_last_of(
DELIM_SEP) + 1;
44 std::string filename = s.substr(ipos, s.length() - ipos);
45 return filename.substr(0, filename.rfind(
"."));
49 std::string::size_type ipos = s.find_last_of(
DELIM_SEP) + 1;
50 std::string filename = s.substr(ipos, s.length() - ipos);
51 std::string::size_type kpos = filename.rfind(
".") + 1;
52 return filename.substr(kpos, filename.length() - kpos);
56 if (from == to)
return 0;
57 std::ifstream in(from, std::ios_base::in | std::ios_base::binary);
58 std::ofstream out(to, std::ios_base::out | std::ios_base::binary);
60 const static int BUF_SIZE = 4096;
64 in.read(&buf[0], BUF_SIZE);
65 out.write(&buf[0], in.gcount());
66 }
while (in.gcount() > 0);
81const std::map<std::string, _enum>
_dict = {
82 {
"ENER",
ENER}, {
"SAMP",
SAMP}, {
"TRAJ",
TRAJ}, {
"ESAMP",
ESAMP}, {
"ETRAJ",
ETRAJ}, {
"CORR",
CORR},
84extern std::map<_enum, bool>
_isopen;
constexpr int FMT_WIDTH_SIZE(int X)
const std::map< std::string, _enum > _dict
std::map< _enum, bool > _isopen
int parse_ostream(const std::string &str)
bool ofs_is_open(const global::OFS::_enum &test)
void closeOFS(std::ofstream &ofs)
void clearFile(std::string &filename)
std::string ParseFilePath(const std::string &s)
std::string ParseFileName(const std::string &s)
bool isFileExists(const std::string &name)
std::string ParseFileExtension(const std::string &s)
int removeFile(std::string &filename)
int copyfile_from_to(const std::string &from, const std::string &to)