Skip to content

Commit

Permalink
chore(userspace/falco): be somewhat more portable, avoiding assuming …
Browse files Browse the repository at this point in the history
…that '/' is the path delim.

Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP authored and poiana committed Sep 9, 2022
1 parent 23df49a commit 11644ec
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions userspace/falco/app_actions/create_requested_paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 11644ec

Please sign in to comment.