chore(userspace/falco): be somewhat more portable, avoiding assuming that '/' is the path delim.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
This commit is contained in:
Federico Di Pierro 2022-09-05 16:15:51 +02:00 committed by poiana
parent 23df49a47f
commit 11644ecafc

View File

@ -18,6 +18,14 @@ limitations under the License.
#include "falco_utils.h"
#include <sys/stat.h>
#ifndef CPPPATH_SEP
#ifdef _MSC_VER
#define CPPPATH_SEP "\\"
#else
#define CPPPATH_SEP "/"
#endif
#endif
using namespace falco::app;
application::run_result application::create_requested_paths()
@ -91,8 +99,8 @@ int application::create_dir(const std::string &path)
// Examples:
// "/tmp/foo/bar" -> "", "tmp", "foo" -> mkdir("/") + mkdir("/tmp/") + midir("/tmp/foo/")
// "tmp/foo/bar" -> "tmp", "foo" -> mkdir("tmp/") + midir("tmp/foo/")
while (getline(f, s, '/') && !f.eof()) {
path_until_token += s + "/";
while (getline(f, s, *CPPPATH_SEP) && !f.eof()) {
path_until_token += s + CPPPATH_SEP;
int ret = mkdir(path_until_token.c_str(), 0600);
if (ret != 0 && errno != EEXIST)
{