diff options
author | Brad King <brad.king@kitware.com> | 2017-11-01 12:38:26 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-11-01 12:38:26 (GMT) |
commit | 7576e9f8a30bb50a3157fe5e3ec493be8a9299bc (patch) | |
tree | c8c2103ad5b5c2e0c30f3233d04153e3586601a1 /Source/kwsys/SystemTools.cxx | |
parent | a57bad6c3d0dbc885bb71dfe465d09a380c35960 (diff) | |
parent | 7d3f33e6129232a6814af47a19a72fd500414508 (diff) | |
download | CMake-7576e9f8a30bb50a3157fe5e3ec493be8a9299bc.zip CMake-7576e9f8a30bb50a3157fe5e3ec493be8a9299bc.tar.gz CMake-7576e9f8a30bb50a3157fe5e3ec493be8a9299bc.tar.bz2 |
Merge branch 'upstream-KWSys' into update-kwsys
* upstream-KWSys:
KWSys 2017-11-01 (6ffca34c)
Diffstat (limited to 'Source/kwsys/SystemTools.cxx')
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index a24a326..72babc3 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -751,15 +751,15 @@ FILE* SystemTools::Fopen(const std::string& file, const char* mode) #endif } -bool SystemTools::MakeDirectory(const char* path) +bool SystemTools::MakeDirectory(const char* path, const mode_t* mode) { if (!path) { return false; } - return SystemTools::MakeDirectory(std::string(path)); + return SystemTools::MakeDirectory(std::string(path), mode); } -bool SystemTools::MakeDirectory(const std::string& path) +bool SystemTools::MakeDirectory(const std::string& path, const mode_t* mode) { if (SystemTools::PathExists(path)) { return SystemTools::FileIsDirectory(path); @@ -774,8 +774,12 @@ bool SystemTools::MakeDirectory(const std::string& path) std::string topdir; while ((pos = dir.find('/', pos)) != std::string::npos) { topdir = dir.substr(0, pos); - Mkdir(topdir); - pos++; + + if (Mkdir(topdir) == 0 && mode != 0) { + SystemTools::SetPermissions(topdir, *mode); + } + + ++pos; } topdir = dir; if (Mkdir(topdir) != 0) { @@ -790,7 +794,10 @@ bool SystemTools::MakeDirectory(const std::string& path) ) { return false; } + } else if (mode != 0) { + SystemTools::SetPermissions(topdir, *mode); } + return true; } |