9
if(std::find(m_SearchPath.begin(), m_SearchPath.end(), TEXT("")) != m_SearchPath.end())
11
m_SearchPath.push_back(TEXT("")); // for fully qualified path
19
void FilePath::AddSearchPath(const NString& searchpath)
21
if(std::find(m_SearchPath.begin(), m_SearchPath.end(), searchpath) != m_SearchPath.end())
23
m_SearchPath.push_back(searchpath);
26
void FilePath::AddSearchPath(const std::vector<NString>& searchpath)
28
for(t_u32 i = 0; i < searchpath.size(); i++)
30
if(std::find(m_SearchPath.begin(), m_SearchPath.end(), searchpath[i]) == m_SearchPath.end())
31
m_SearchPath.push_back(searchpath[i]);
35
NString FilePath::GetPathToFile(const TCHAR* filename) const
37
NString FileName = GetFile(filename);
39
int loc = (int)FileName.FindLastOccurence(TEXT('\\'));
42
loc = (int)FileName.FindLastOccurence(TEXT('/'));
46
FileName = FileName.GetSubString(0, loc);
48
FileName = NString(TEXT("."));
52
NString FilePath::GetFile(const TCHAR* filename) const
54
INL_RETURN_VALUE_IF_NULL(filename, NString(TEXT("")));
55
if(filename == TEXT(""))
56
return NString(TEXT(""));
58
NString FileName = filename;
60
if(GFileManager.FileExist(FileName.GetTCharPtr()))
63
for(t_u32 i = 0; i < m_SearchPath.size(); i++)
65
if(m_SearchPath[i].Size() == 0)
68
NString FilePath = m_SearchPath[i] + INL_PATH_SEPARATOR_STRING + filename;
69
if(GFileManager.FileExist(FilePath.GetTCharPtr()))
73
// Still not found. Then peel off the root of the filename and append our custom search path.
74
// filename = "MediaProg/UI3DGraphics/MyFile.txt"
76
// CustomPath0/UI3DGraphics/MyFile.txt
77
// CustomPath1/UI3DGraphics/MyFile.txt
78
// CustomPath2/UI3DGraphics/MyFile.txt
79
// CustomPath3/UI3DGraphics/MyFile.txt
80
// CustomPath0/MyFile.txt
81
// CustomPath1/MyFile.txt
82
// CustomPath2/MyFile.txt
83
// CustomPath3/MyFile.txt
87
for(t_size i = 0; i < m_SearchPath.size(); i++)
91
while(FileName.FindFirstOccurenceOf(TEXT("\\/")) != std::string::npos)
93
pos = FileName.FindFirstOccurenceOf(TEXT("\\/")) + 1;
95
FileName = FileName.GetSubString(pos, FileName.Length()- pos);
96
PathName = m_SearchPath[i] + INL_PATH_SEPARATOR_STRING + FileName;
97
if(GFileManager.FileExist(PathName.GetTCharPtr()))
102
nuxDebugMsg(TEXT("FilePath::GetFile] Cannot find file: %s"), filename);
103
return NString(TEXT(""));