aboutsummaryrefslogtreecommitdiff
path: root/libs/game_bethesda/src/games/nehrim/nehrimmoddatachecker.cpp
blob: 3ec4eb099bcd7a720ecbc303ef21f3c18c665215 (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
29
30
#include "nehrimmoddatachecker.h"

MOBase::ModDataChecker::CheckReturn NehrimModDataChecker::dataLooksValid(
    std::shared_ptr<const MOBase::IFileTree> fileTree) const
{
  // Check with Gamebryo stuff:
  auto check = GamebryoModDataChecker::dataLooksValid(fileTree);
  if (check == CheckReturn::VALID) {
    return check;
  }

  // Check for OBSE_ files:
  for (auto const& entry : *fileTree) {
    if (entry->isDir() || !entry->name().startsWith("OBSE", Qt::CaseInsensitive)) {
      return CheckReturn::INVALID;
    }
  }

  return CheckReturn::FIXABLE;
}

std::shared_ptr<MOBase::IFileTree>
NehrimModDataChecker::fix(std::shared_ptr<MOBase::IFileTree> fileTree) const
{
  // If we arrive here, it means all files starts with OBSE.
  auto data = fileTree->createOrphanTree();
  auto obse = data->addDirectory("OBSE/Plugins");
  obse->merge(fileTree);
  return data;
}