aboutsummaryrefslogtreecommitdiff
path: root/libs/game_bethesda/src/games/oblivion/oblivionmoddatachecker.cpp
blob: 30a74ee017285cfea9b720b3ccf41bdca9f6eed5 (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 "oblivionmoddatachecker.h"

MOBase::ModDataChecker::CheckReturn OblivionModDataChecker::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>
OblivionModDataChecker::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;
}