31#define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR)
41int mkdir(
const char *path, mode_t mode)
47 return ::mkdir(path, mode);
51int mkpath(std::string s, mode_t mode)
61 if (s[s.size() - 1] !=
'/')
64 while ((pos = s.find_first_of(
'/', pre)) != std::string::npos)
66 dir = s.substr(0, pos++);
71 if (stat(dir.c_str(), &st))
73 if (
errno != ENOENT || ((mdret =
mkdir(dir.c_str(), mode)) &&
errno != EEXIST))
80 if (!S_ISDIR(st.st_mode))
93 size_t size = strftime(cstr,
sizeof(cstr), format, &tm);
95 return std::string(cstr, size);
98void replace_all(std::string &subject,
const std::string &search,
const std::string &replace)
101 while ((pos = subject.find(search, pos)) != std::string::npos)
103 subject.replace(pos, search.length(), replace);
104 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)