diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-12-10 07:22:22 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-12-10 07:22:22 +0100 |
commit | aa61bbe9e414648399aff2802df5b587dee1a084 (patch) | |
tree | ff7809bea445bb76c9fd27a3245e1b2cb7c72596 /mmc_updater/src/MacBundle.cpp | |
parent | 3f5c46a1c4b27e82976e0067e4ec2d6abfffd9ba (diff) | |
parent | 712b87c643bbd7bc4ed2cfd459d0b9fdb69e5f0d (diff) | |
download | MultiMC-aa61bbe9e414648399aff2802df5b587dee1a084.tar MultiMC-aa61bbe9e414648399aff2802df5b587dee1a084.tar.gz MultiMC-aa61bbe9e414648399aff2802df5b587dee1a084.tar.lz MultiMC-aa61bbe9e414648399aff2802df5b587dee1a084.tar.xz MultiMC-aa61bbe9e414648399aff2802df5b587dee1a084.zip |
Merge branch 'develop' of github.com:MultiMC/MultiMC5 into develop
Conflicts:
CMakeLists.txt
gui/MainWindow.cpp
Diffstat (limited to 'mmc_updater/src/MacBundle.cpp')
-rw-r--r-- | mmc_updater/src/MacBundle.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
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<int>(infoPlist.size())); + + // save the icon to Contents/Resources/<appname>.icns + FileUtils::writeFile((resourceDir + '/' + m_appName + ".icns").c_str(),icon.c_str(),static_cast<int>(icon.size())); + + // copy the app binary to Contents/MacOS/<appname> + 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; +} + |