| Line 160... |
Line 160... |
| 160 |
return this->LoadFilesystem(dir, "", maxPatch);
|
160 |
return this->LoadFilesystem(dir, "", maxPatch);
|
| 161 |
}
|
161 |
}
|
| 162 |
|
162 |
|
| 163 |
bool CVirtualFileSystem::LoadFilesystem(const Utils::String &dir, const Utils::String &mod, int maxPatch)
|
163 |
bool CVirtualFileSystem::LoadFilesystem(const Utils::String &dir, const Utils::String &mod, int maxPatch)
|
| 164 |
{
|
164 |
{
|
| 165 |
m_sDir = dir;
|
165 |
m_sDir = dir.findReplace("\\", "/");
|
| 166 |
|
166 |
|
| 167 |
this->_clear();
|
167 |
this->_clear();
|
| 168 |
|
168 |
|
| - |
|
169 |
// if we are in the addon directory, then also read the previous directory
|
| - |
|
170 |
Utils::String s = dir.token("/", -1);
|
| - |
|
171 |
if ( !this->m_sAddon.empty() && dir.token("/", -1).Compare(this->m_sAddon) ) {
|
| - |
|
172 |
//LoadFilesystem(dir.tokens("/", 1, -2), "", 0);
|
| - |
|
173 |
}
|
| - |
|
174 |
|
| 169 |
int number = 1;
|
175 |
int number = 1;
|
| 170 |
while ( CFileIO::Exists(dir + "/" + Utils::String::PadNumber(number, 2) + ".cat") )
|
176 |
while ( CFileIO::Exists(dir + "/" + Utils::String::PadNumber(number, 2) + ".cat") )
|
| 171 |
{
|
177 |
{
|
| 172 |
if ( maxPatch && maxPatch < number ) break;
|
178 |
if ( maxPatch && maxPatch < number ) break;
|
| 173 |
Utils::String file = dir + "/" + Utils::String::PadNumber(number, 2);
|
179 |
Utils::String file = dir + "/" + Utils::String::PadNumber(number, 2);
|
| Line 208... |
Line 214... |
| 208 |
else this->_addFile(sDir + "/" + strNode->str.ToString(), Dir.File(strNode->str).ToString(), m_pMap);
|
214 |
else this->_addFile(sDir + "/" + strNode->str.ToString(), Dir.File(strNode->str).ToString(), m_pMap);
|
| 209 |
}
|
215 |
}
|
| 210 |
}
|
216 |
}
|
| 211 |
}
|
217 |
}
|
| 212 |
|
218 |
|
| - |
|
219 |
|
| - |
|
220 |
void CVirtualFileSystem::_removeSameFile(const Utils::String &sFile, const Utils::String &sDest, const Utils::String &ext, FileList *pList)
|
| - |
|
221 |
{
|
| - |
|
222 |
CFileIO F(sFile);
|
| - |
|
223 |
|
| - |
|
224 |
Utils::String newFile = F.ChangeFileExtension(ext).ToString();
|
| - |
|
225 |
newFile = newFile.lower();
|
| - |
|
226 |
|
| - |
|
227 |
FileListItr itr = pList->find(newFile);
|
| - |
|
228 |
if ( itr != pList->end() ) {
|
| - |
|
229 |
if ( !CFileIO((*pList)[newFile]).dir().Compare(CFileIO(sDest).dir()) ) {
|
| - |
|
230 |
pList->erase(newFile);
|
| - |
|
231 |
}
|
| - |
|
232 |
}
|
| - |
|
233 |
}
|
| - |
|
234 |
|
| 213 |
void CVirtualFileSystem::_addFile(const Utils::String &sFile, const Utils::String &sDest, FileList *pList)
|
235 |
void CVirtualFileSystem::_addFile(const Utils::String &sFile, const Utils::String &sDest, FileList *pList)
|
| 214 |
{
|
236 |
{
|
| - |
|
237 |
Utils::String file = sFile.asFilename().removeIf(0, '/');
|
| - |
|
238 |
|
| - |
|
239 |
// check file extension, remove any patching files in previous files
|
| - |
|
240 |
CFileIO F(file);
|
| - |
|
241 |
if ( F.CheckFileExtension("bob") || F.CheckFileExtension("pbd") || F.CheckFileExtension("bod") ) {
|
| - |
|
242 |
_removeSameFile(file, sDest, "pbb", pList);
|
| - |
|
243 |
_removeSameFile(file, sDest, "bob", pList);
|
| - |
|
244 |
_removeSameFile(file, sDest, "pbd", pList);
|
| - |
|
245 |
}
|
| - |
|
246 |
|
| 215 |
(*pList)[sFile.asFilename().removeIf(0, '/').lower()] = sDest.findReplace("//", "/");
|
247 |
(*pList)[file.lower()] = sDest.findReplace("//", "/");
|
| 216 |
}
|
248 |
}
|
| 217 |
void CVirtualFileSystem::_addModFile(const Utils::String &sFile, const Utils::String &sMod, FileList *pList)
|
249 |
void CVirtualFileSystem::_addModFile(const Utils::String &sFile, const Utils::String &sMod, FileList *pList)
|
| 218 |
{
|
250 |
{
|
| 219 |
this->_addFile(sFile, sMod + "::" + sFile, pList);
|
251 |
this->_addFile(sFile, sMod + "::" + sFile, pList);
|
| 220 |
}
|
252 |
}
|
| Line 312... |
Line 344... |
| 312 |
}
|
344 |
}
|
| 313 |
FileListItr itr = m_pModMap->find(CFileIO(toFile).fullFilename().lower().c_str());
|
345 |
FileListItr itr = m_pModMap->find(CFileIO(toFile).fullFilename().lower().c_str());
|
| 314 |
if ( itr == m_pModMap->end() ) itr = m_pModMap->find(CFileIO(_convertExtension(toFile)).fullFilename().lower().c_str());
|
346 |
if ( itr == m_pModMap->end() ) itr = m_pModMap->find(CFileIO(_convertExtension(toFile)).fullFilename().lower().c_str());
|
| 315 |
if ( itr != m_pModMap->end() ) return itr->second;
|
347 |
if ( itr != m_pModMap->end() ) return itr->second;
|
| 316 |
}
|
348 |
}
|
| - |
|
349 |
|
| 317 |
else if ( m_pMap && !m_pMap->empty() ) {
|
350 |
if ( m_pMap && !m_pMap->empty() ) {
|
| 318 |
if ( !m_sAddon.empty() ) {
|
351 |
if ( !m_sAddon.empty() ) {
|
| 319 |
FileListItr aitr = m_pMap->find(CFileIO(m_sAddon + "/" + toFile).fullFilename().lower().c_str());
|
352 |
FileListItr aitr = m_pMap->find(CFileIO(m_sAddon + "/" + toFile).fullFilename().lower().c_str());
|
| 320 |
if ( aitr == m_pMap->end() ) aitr = m_pMap->find(CFileIO(_convertExtension(m_sAddon + "/" + file)).fullFilename().lower().c_str());
|
353 |
if ( aitr == m_pMap->end() ) aitr = m_pMap->find(CFileIO(_convertExtension(m_sAddon + "/" + file)).fullFilename().lower().c_str());
|
| 321 |
if ( aitr != m_pMap->end() ) return aitr->second;
|
354 |
if ( aitr != m_pMap->end() ) return aitr->second;
|
| 322 |
}
|
355 |
}
|
| Line 749... |
Line 782... |
| 749 |
_lBodiesSections->pushBack("SBTYPE_DOCKPOINT", "SBTYPE_DOCKPOINT");
|
782 |
_lBodiesSections->pushBack("SBTYPE_DOCKPOINT", "SBTYPE_DOCKPOINT");
|
| 750 |
_lBodiesSections->pushBack("SBTYPE_SMALLJET", "SBTYPE_SMALLJET");
|
783 |
_lBodiesSections->pushBack("SBTYPE_SMALLJET", "SBTYPE_SMALLJET");
|
| 751 |
}
|
784 |
}
|
| 752 |
}
|
785 |
}
|
| 753 |
|
786 |
|
| - |
|
787 |
|
| - |
|
788 |
/////////////////////////////////////////////////////////////////////////////////////////
|
| - |
|
789 |
// DEBUG Functions
|
| - |
|
790 |
|
| - |
|
791 |
|
| - |
|
792 |
void CVirtualFileSystem::DEBUG_LogContents(const Utils::String &sFile)
|
| - |
|
793 |
{
|
| - |
|
794 |
CFileIO File(sFile);
|
| - |
|
795 |
|
| - |
|
796 |
if ( File.startWrite() ) {
|
| - |
|
797 |
if ( m_pMap ) {
|
| - |
|
798 |
for(FileListItr itr = m_pMap->begin(); itr != m_pMap->end(); itr++) {
|
| - |
|
799 |
Utils::String line = itr->first + " => " + itr->second + "\r\n";
|
| - |
|
800 |
File.write(line.c_str(), line.length());
|
| - |
|
801 |
}
|
| - |
|
802 |
}
|
| - |
|
803 |
|
| - |
|
804 |
File.close();
|
| - |
|
805 |
}
|
| - |
|
806 |
}
|
| - |
|
807 |
|
| 754 |
} //NAMESPACE
|
808 |
} //NAMESPACE
|
| 755 |
|
809 |
|