-
-
Notifications
You must be signed in to change notification settings - Fork 452
/
Copy pathCFilePathTranslator.cpp
89 lines (72 loc) · 2.31 KB
/
CFilePathTranslator.cpp
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*****************************************************************************
*
* PROJECT: Multi Theft Auto
* LICENSE: See LICENSE in the top level directory
* FILE: Client/core/CFilePathTranslator.cpp
* PURPOSE: Easy interface to file paths
*
* Multi Theft Auto is available from https://multitheftauto.com/
*
*****************************************************************************/
#include "StdInc.h"
#include "CFilePathTranslator.h"
#include <filesystem>
extern std::filesystem::path g_gtaDirectory;
CFilePathTranslator::CFilePathTranslator()
{
}
CFilePathTranslator::~CFilePathTranslator()
{
}
bool CFilePathTranslator::GetFileFromModPath(const std::string& FileToGet, std::string& TranslatedFilePathOut)
{
// Translate the path to this file.
TranslatedFilePathOut = m_ModPath;
TranslatedFilePathOut += '\\';
TranslatedFilePathOut += FileToGet;
return true;
}
bool CFilePathTranslator::GetFileFromWorkingDirectory(const std::string& FileToGet, std::string& TranslatedFilePathOut)
{
// Translate the path to this file.
TranslatedFilePathOut = m_WorkingDirectory;
TranslatedFilePathOut += '\\';
TranslatedFilePathOut += FileToGet;
return true;
}
void CFilePathTranslator::GetModPath(std::string& ModPathOut)
{
ModPathOut = m_ModPath;
}
void CFilePathTranslator::SetModPath(const std::string& PathBasedOffWorkingDirectory)
{
m_ModPath = m_WorkingDirectory;
m_ModPath += '\\';
m_ModPath += PathBasedOffWorkingDirectory;
}
void CFilePathTranslator::SetCurrentWorkingDirectory(const std::string& PathBasedOffModuleRoot)
{
std::string RootDirectory;
// Get the root directory.
GetMTASARootDirectory(RootDirectory);
// Store it
m_WorkingDirectory = RootDirectory;
m_WorkingDirectory += '\\';
m_WorkingDirectory += PathBasedOffModuleRoot;
}
void CFilePathTranslator::UnSetCurrentWorkingDirectory()
{
m_WorkingDirectory = "";
}
void CFilePathTranslator::GetCurrentWorkingDirectory(std::string& WorkingDirectoryOut)
{
WorkingDirectoryOut = m_WorkingDirectory;
}
void CFilePathTranslator::GetGTARootDirectory(std::string& ModuleRootDirOut)
{
ModuleRootDirOut = PathToUtf8(g_gtaDirectory);
}
void CFilePathTranslator::GetMTASARootDirectory(std::string& InstallRootDirOut)
{
InstallRootDirOut = GetMTASABaseDir();
}