diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2020-11-06 16:13:06 -0500 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2020-11-07 20:16:26 -0500 |
| commit | baa5c3abee4960046e4fe1e2240dd1e73253c43c (patch) | |
| tree | 332dcfbc6c85978e507ed0c908d97195e4b2981d /src/createinstancedialog.cpp | |
| parent | b962d8081624ffdd7ab5cecbb6b2701b000b6b73 (diff) | |
documentation
use an okay flag in PathsPage to avoid calling checkPaths() in ready() and make stuff mutable
moved a few things around
Diffstat (limited to 'src/createinstancedialog.cpp')
| -rw-r--r-- | src/createinstancedialog.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/createinstancedialog.cpp b/src/createinstancedialog.cpp index f52d3ebd..1c1b62d0 100644 --- a/src/createinstancedialog.cpp +++ b/src/createinstancedialog.cpp @@ -13,6 +13,12 @@ using namespace MOBase; class Failed {}; +// create() will create all the directories in `target`; if any path component +// fails to create, it will throw Failed +// +// unless commit() is called, all the created directories will be deleted in +// the destructor +// class DirectoryCreator { public: @@ -39,6 +45,7 @@ public: { try { + // delete each directory starting from the end for (auto itor=m_created.rbegin(); itor!=m_created.rend(); ++itor) { const auto r = shell::DeleteDirectoryRecursive(*itor); if (!r) { @@ -62,6 +69,7 @@ private: { try { + // split on separators const QString s = QDir::toNativeSeparators(target.absolutePath()); const QStringList cs = s.split("\\"); @@ -69,8 +77,10 @@ private: return; } + // root directory QDir d(cs[0]); + // for each directory after the root for (int i=1; i<cs.size(); ++i) { d = d.filePath(cs[i]); |
