summaryrefslogtreecommitdiff
path: root/Source/kwsys/SystemTools.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-11-01 08:38:26 -0400
committerBrad King <brad.king@kitware.com>2017-11-01 08:38:26 -0400
commit7576e9f8a30bb50a3157fe5e3ec493be8a9299bc (patch)
treec8c2103ad5b5c2e0c30f3233d04153e3586601a1 /Source/kwsys/SystemTools.cxx
parenta57bad6c3d0dbc885bb71dfe465d09a380c35960 (diff)
parent7d3f33e6129232a6814af47a19a72fd500414508 (diff)
downloadcmake-7576e9f8a30bb50a3157fe5e3ec493be8a9299bc.tar.gz
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.cxx17
1 files changed, 12 insertions, 5 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index a24a3262b7..72babc31ca 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;
}