fix(userspace/falco): fix create_dir behaviour

Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
This commit is contained in:
Roberto Scolaro
2023-11-06 18:52:19 +00:00
committed by poiana
parent fde8da0e5c
commit 92b42c9474

View File

@@ -92,13 +92,15 @@ falco::app::run_result falco::app::actions::create_requested_paths(falco::app::s
return run_result::ok();
}
// This function operates like `mkdir -p` excluding the last part of
// the path which we assume to be the filename.
static int create_dir(const std::string &path)
{
std::filesystem::path dirPath(path);
try {
std::filesystem::create_directories(dirPath);
std::filesystem::create_directories(dirPath.parent_path());
} catch (const std::exception& ex) {
return -1;
}