From 6aa9bd0f77dcb5128167fae62e32aa5252fe85c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 2 Dec 2013 00:55:24 +0100 Subject: Renew the updater branch Now with some actual consensus on what the updater will do! --- mmc_updater/src/MacBundle.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 mmc_updater/src/MacBundle.cpp (limited to 'mmc_updater/src/MacBundle.cpp') diff --git a/mmc_updater/src/MacBundle.cpp b/mmc_updater/src/MacBundle.cpp new file mode 100644 index 00000000..205869eb --- /dev/null +++ b/mmc_updater/src/MacBundle.cpp @@ -0,0 +1,53 @@ +#include "MacBundle.h" + +#include "FileUtils.h" +#include "Log.h" + +MacBundle::MacBundle(const std::string& path, const std::string& appName) +: m_appName(appName) +{ + m_path = path + '/' + appName + ".app"; +} + +std::string MacBundle::bundlePath() const +{ + return m_path; +} + +void MacBundle::create(const std::string& infoPlist, + const std::string& icon, + const std::string& exePath) +{ + try + { + // create the bundle directories + FileUtils::mkpath(m_path.c_str()); + + std::string contentDir = m_path + "/Contents"; + std::string resourceDir = contentDir + "/Resources"; + std::string binDir = contentDir + "/MacOS"; + + FileUtils::mkpath(resourceDir.c_str()); + FileUtils::mkpath(binDir.c_str()); + + // create the Contents/Info.plist file + FileUtils::writeFile((contentDir + "/Info.plist").c_str(),infoPlist.c_str(),static_cast(infoPlist.size())); + + // save the icon to Contents/Resources/.icns + FileUtils::writeFile((resourceDir + '/' + m_appName + ".icns").c_str(),icon.c_str(),static_cast(icon.size())); + + // copy the app binary to Contents/MacOS/ + m_exePath = binDir + '/' + m_appName; + FileUtils::copyFile(exePath.c_str(),m_exePath.c_str()); + } + catch (const FileUtils::IOException& exception) + { + LOG(Error,"Unable to create app bundle. " + std::string(exception.what())); + } +} + +std::string MacBundle::executablePath() const +{ + return m_exePath; +} + -- cgit v1.2.3