From baa5c3abee4960046e4fe1e2240dd1e73253c43c Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Fri, 6 Nov 2020 16:13:06 -0500 Subject: documentation use an okay flag in PathsPage to avoid calling checkPaths() in ready() and make stuff mutable moved a few things around --- src/createinstancedialog.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/createinstancedialog.cpp') 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