From 09ab5570c0435cdfeb9f0b3479a9351ba09f6a94 Mon Sep 17 00:00:00 2001 From: Thomas De Maet <thomas.demaet@uclouvain.be> Date: Tue, 28 Jan 2014 09:59:32 +0000 Subject: [PATCH] remise en route (partielle) du module Subsurface pour le cas-test Richards --- Common/OS.cpp | 17 +++++++++++++++++ Common/OS.h | 1 + 2 files changed, 18 insertions(+) diff --git a/Common/OS.cpp b/Common/OS.cpp index 210c294e24..6a6a91b8ea 100644 --- a/Common/OS.cpp +++ b/Common/OS.cpp @@ -350,6 +350,23 @@ int CreateDirectory(const std::string &dirName) return 1; } +void CreatePath(const std::string &fullPath) +{ + size_t lastp = fullPath.find_last_of('/'); //TODO ?? win ==> backslash ?? + if(lastp == std::string::npos) return; + std::string dirname = std::string(fullPath, 0, lastp); + size_t cur = 0; + while(cur != std::string::npos) { + cur = dirname.find("/", cur + 1); + CreateDirectory( dirname.substr(0,cur) ); +/*#if defined(WIN32) && !defined(__CYGWIN__) + mkdir(dirname.substr(0,cur).c_str()); +#else + mkdir(dirname.substr(0,cur).c_str(),S_IRWXG|S_IRWXU); +#endif*/ + } +} + int KillProcess(int pid) { #if defined(WIN32) && !defined(__CYGWIN__) diff --git a/Common/OS.h b/Common/OS.h index 1a0cbb95f6..d856f2a340 100644 --- a/Common/OS.h +++ b/Common/OS.h @@ -23,6 +23,7 @@ int UnlinkFile(const std::string &fileName); int StatFile(const std::string &fileName); int KillProcess(int pid); int CreateDirectory(const std::string &dirName); +void CreatePath(const std::string &fullPath); int SystemCall(const std::string &command, bool blocking=false); std::string GetCurrentWorkdir(); void RedirectIOToConsole(); -- GitLab