mirror of
https://github.com/badaix/snapcast.git
synced 2025-08-03 08:39:49 +02:00
recusive mkdir
This commit is contained in:
parent
41db245efc
commit
478dcff713
2 changed files with 19 additions and 1 deletions
|
@ -126,6 +126,24 @@ static std::vector<std::string> split(const std::string &s, char delim)
|
|||
}
|
||||
|
||||
|
||||
static int mkdirRecursive(const char *path, mode_t mode)
|
||||
{
|
||||
std::vector<std::string> pathes = split(path, '/');
|
||||
std::stringstream ss;
|
||||
int res = 0;
|
||||
for (const auto& p: pathes)
|
||||
{
|
||||
if (p.empty())
|
||||
continue;
|
||||
ss << "/" << p;
|
||||
int res = mkdir(ss.str().c_str(), mode);
|
||||
if ((res != 0) && (errno != EEXIST))
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
static std::string execGetOutput(const std::string& cmd)
|
||||
{
|
||||
std::shared_ptr<FILE> pipe(popen(cmd.c_str(), "r"), pclose);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue