31 #define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR)
41 int mkdir(
const char *path, mode_t mode)
51 int mkpath(std::string s, mode_t mode)
58 if (s[s.size() - 1] !=
'/')
61 while ((pos = s.find_first_of(
'/', pre)) != std::string::npos)
63 dir = s.substr(0, pos++);
68 if (stat(dir.c_str(), &st))
70 if (
errno != ENOENT || ((mdret =
mkdir(dir.c_str(), mode)) &&
errno != EEXIST))
77 if (!S_ISDIR(st.st_mode))
86 std::string
format_time(
const std::tm &tm,
const char *format)
90 size_t size = strftime(cstr,
sizeof(cstr), format, &tm);
92 return std::string(cstr, size);
95 void replace_all(std::string &subject,
const std::string &search,
const std::string &replace)
98 while ((pos = subject.find(search, pos)) != std::string::npos)
100 subject.replace(pos, search.length(), replace);
101 pos += replace.length();
Namespace to encapsulate INDI client, drivers, and mediator classes.
int mkdir(const char *path, mode_t mode)
std::string format_time(const std::tm &tm, const char *format)
void replace_all(std::string &subject, const std::string &search, const std::string &replace)
int mkpath(std::string s, mode_t mode)