aboutsummaryrefslogtreecommitdiff
path: root/launcher/minecraft/launch/CreateGameFolders.cpp
blob: 4081e72eda2fca69f072913925a14611cfde9d4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "CreateGameFolders.h"
#include "minecraft/MinecraftInstance.h"
#include "launch/LaunchTask.h"
#include "FileSystem.h"

CreateGameFolders::CreateGameFolders(LaunchTask* parent): LaunchStep(parent)
{
}

void CreateGameFolders::executeTask()
{
    auto instance = m_parent->instance();
    std::shared_ptr<MinecraftInstance> minecraftInstance = std::dynamic_pointer_cast<MinecraftInstance>(instance);

    if(!FS::ensureFolderPathExists(minecraftInstance->gameRoot()))
    {
        emit logLine("Couldn't create the main game folder", MessageLevel::Error);
        emitFailed(tr("Couldn't create the main game folder"));
        return;
    }

    // HACK: this is a workaround for MCL-3732 - 'server-resource-packs' folder is created.
    if(!FS::ensureFolderPathExists(FS::PathCombine(minecraftInstance->gameRoot(), "server-resource-packs")))
    {
        emit logLine("Couldn't create the 'server-resource-packs' folder", MessageLevel::Error);
    }
    emitSucceeded();
}