mirror of https://github.com/AxioDL/metaforce.git
driver/main: Factor out project finding code to its own function
Keeps the logic contained within its own function and makes the assignment more straightforward within main().
This commit is contained in:
parent
1fb18dbf26
commit
fd61ba6cc7
|
@ -85,6 +85,24 @@ static void AthenaExc(athena::error::Level level, const char* file, const char*,
|
||||||
static hecl::SystemChar cwdbuf[1024];
|
static hecl::SystemChar cwdbuf[1024];
|
||||||
hecl::SystemString ExeDir;
|
hecl::SystemString ExeDir;
|
||||||
|
|
||||||
|
static std::unique_ptr<hecl::Database::Project> FindProject(hecl::SystemStringView cwd) {
|
||||||
|
const hecl::ProjectRootPath rootPath = hecl::SearchForProject(cwd);
|
||||||
|
if (!rootPath) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const size_t ErrorRef = logvisor::ErrorCount;
|
||||||
|
auto newProj = std::make_unique<hecl::Database::Project>(rootPath);
|
||||||
|
if (logvisor::ErrorCount > ErrorRef) {
|
||||||
|
#if WIN_PAUSE
|
||||||
|
system("PAUSE");
|
||||||
|
#endif
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return newProj;
|
||||||
|
}
|
||||||
|
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
int wmain(int argc, const wchar_t** argv)
|
int wmain(int argc, const wchar_t** argv)
|
||||||
#else
|
#else
|
||||||
|
@ -235,20 +253,9 @@ int main(int argc, const char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Attempt to find hecl project */
|
/* Attempt to find hecl project */
|
||||||
hecl::ProjectRootPath rootPath = hecl::SearchForProject(info.cwd);
|
auto project = FindProject(info.cwd);
|
||||||
std::unique_ptr<hecl::Database::Project> project;
|
if (project != nullptr) {
|
||||||
if (rootPath) {
|
info.project = project.get();
|
||||||
size_t ErrorRef = logvisor::ErrorCount;
|
|
||||||
hecl::Database::Project* newProj = new hecl::Database::Project(rootPath);
|
|
||||||
if (logvisor::ErrorCount > ErrorRef) {
|
|
||||||
#if WIN_PAUSE
|
|
||||||
system("PAUSE");
|
|
||||||
#endif
|
|
||||||
delete newProj;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
project.reset(newProj);
|
|
||||||
info.project = newProj;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Construct selected tool */
|
/* Construct selected tool */
|
||||||
|
|
Loading…
Reference in New Issue