aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/platform/MSWindowsUtil.cpp
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@ubuntu.com>2018-06-04 21:05:54 -0400
committerLibravatarUnit 193 <unit193@ubuntu.com>2018-06-04 21:05:54 -0400
commit4d1efbbd1aa971401202bb1bd436742c57170980 (patch)
treea3eb68d768223982546ee6bf35bd533b1e0905bc /src/lib/platform/MSWindowsUtil.cpp
parent5f6625ebd476340745d578b08620dbe4d27d1a9b (diff)
parent4a8bfd06e73d7f051f0b39e19e57616c7bbb8ad1 (diff)
Update upstream source from tag 'upstream/2.1.1+dfsg'
Update to upstream version '2.1.1+dfsg' with Debian dir fae8a5463c58b9ee303cb04f24606a56a5a08fba
Diffstat (limited to 'src/lib/platform/MSWindowsUtil.cpp')
-rw-r--r--src/lib/platform/MSWindowsUtil.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lib/platform/MSWindowsUtil.cpp b/src/lib/platform/MSWindowsUtil.cpp
index 4b51781..b657906 100644
--- a/src/lib/platform/MSWindowsUtil.cpp
+++ b/src/lib/platform/MSWindowsUtil.cpp
@@ -62,3 +62,23 @@ MSWindowsUtil::getErrorString(HINSTANCE hinstance, DWORD error, DWORD id)
return result;
}
}
+
+/*
+
+This is a quick and dirty iterative CreateDirectory() wrapper that does zero
+error checking. A much better cross-platform option exists in C++17 via
+std::filesystem. If/when the project is updated to use 17 this function should
+absolutley be replaced!
+
+*/
+
+void
+MSWindowsUtil::createDirectory(const std::string& path, bool stripLast)
+{
+ // create parent directories
+ for (auto pos = path.find_first_of('\\'); pos != std::string::npos; pos = path.find_first_of('\\', pos + 1))
+ CreateDirectory(path.substr(0, pos).c_str(), NULL);
+ if (!stripLast)
+ // create innermost directory
+ CreateDirectory(path.c_str(), NULL);
+}