51 throw Rexception(
"Rtools::Flags2String()",
"Bad args: fnam==nullptr");
55 if (flags & fnam->
mask) {
56 if (!rval.empty()) rval += delim;
70 res = ::strtol(str.c_str(), &endptr, base);
71 if (*endptr == 0)
return true;
73 emsg.
Init(
"Rtools::String2Long",
74 string(
"conversion error in '") + str +
"'");
86 res = ::strtoul(str.c_str(), &endptr, base);
87 if (*endptr == 0)
return true;
89 emsg.
Init(
"Rtools::String2Long",
90 string(
"conversion error in '") + str +
"'");
100 if (nbackup == 0)
return true;
102 size_t dotpos = fname.find_last_of(
'.');
103 string fbase = fname.substr(0,dotpos);
104 string fext = fname.substr(dotpos);
107 emsg.
Init(
"Rtools::CreateBackupFile",
108 "only up to 99 backup levels supported");
112 vector<string> fnames;
113 fnames.push_back(fname);
114 for (
size_t i=1; i<=nbackup; i++) {
116 ::snprintf(fnum,
sizeof(fnum),
"%d",
int(i));
117 fnames.push_back(fbase +
"_" + fnum + fext);
120 for (
size_t i=nbackup; i>0; i--) {
121 string fnam_new = fnames[i];
122 string fnam_old = fnames[i-1];
125 int irc = ::stat(fnam_old.c_str(), &sbuf);
127 if (errno == ENOENT)
continue;
128 emsg.
InitErrno(
"Rtools::CreateBackupFile",
129 string(
"stat() for '") + fnam_old +
"'failed: ", errno);
132 if (S_ISREG(sbuf.st_mode) == 0) {
133 emsg.
Init(
"Rtools::CreateBackupFile",
134 "backups only supported for regular files");
139 irc = ::rename(fnam_old.c_str(), fnam_new.c_str());
141 emsg.
InitErrno(
"Rtools::CreateBackupFile",
142 string(
"rename() for '") + fnam_old +
"' -> '" +
143 fnam_new +
"'failed: ", errno);
175 cerr <<
"Catch2Cerr-E: exception '" << e.
ErrMsg().
Text()
177 <<
" caught and dropped in " << msg << endl;
178 }
catch (exception& e) {
179 cerr <<
"Catch2Cerr-E: exception '" << e.
what()
180 <<
"' caught and dropped in " << msg << endl;
182 cerr <<
"Catch2Cerr-E: non std::exception"
183 <<
" caught and dropped in " << msg << endl;
const std::string & Meth() const
FIXME_docs.
void Init(const std::string &meth, const std::string &text)
FIXME_docs.
const std::string & Text() const
FIXME_docs.
void InitErrno(const std::string &meth, const std::string &text, int errnum)
FIXME_docs.
virtual const char * what() const noexcept
FIXME_docs.
const RerrMsg & ErrMsg() const
FIXME_docs.
bool FindOpt(const std::string &name) const
FIXME_docs.
const std::string & Path() const
FIXME_docs.
Declaration of class ReventLoop.