| Line 919... |
Line 919... |
| 919 |
lPatches.pushBack(fit->baseName(), newname);
|
919 |
lPatches.pushBack(fit->baseName(), newname);
|
| 920 |
}
|
920 |
}
|
| 921 |
|
921 |
|
| 922 |
// rename the file
|
922 |
// rename the file
|
| 923 |
fit->FixOriginalName();
|
923 |
fit->FixOriginalName();
|
| 924 |
CLog::logf(CLog::Log_Install, 2, "Adjusting fake patch number, %s => %s", fit->getNameDirectory(this).c_str(), (newname + L"." + fit->fileExt()).c_str());
|
924 |
CLog::logf(CLog::Log_Install, 2, L"Adjusting fake patch number, %s => %s", fit->getNameDirectory(this).c_str(), (newname + L"." + fit->fileExt()).c_str());
|
| 925 |
fit->setName(newname + L"." + fit->fileExt());
|
925 |
fit->setName(newname + L"." + fit->fileExt());
|
| 926 |
|
926 |
|
| 927 |
// find the next gap
|
927 |
// find the next gap
|
| 928 |
if ( !isOpposite ) {
|
928 |
if ( !isOpposite ) {
|
| 929 |
startfake = pPackages->findNextFakePatch(startfake + 1);
|
929 |
startfake = pPackages->findNextFakePatch(startfake + 1);
|
| Line 939... |
Line 939... |
| 939 |
if ( !fit->isAutoTextFile() )
|
939 |
if ( !fit->isAutoTextFile() )
|
| 940 |
continue;
|
940 |
continue;
|
| 941 |
|
941 |
|
| 942 |
Utils::WString newname = SPK::FormatTextName(starttext, pPackages->GetLanguage(), (pPackages->GetCurrentGameFlags() & EXEFLAG_TCTEXT));
|
942 |
Utils::WString newname = SPK::FormatTextName(starttext, pPackages->GetLanguage(), (pPackages->GetCurrentGameFlags() & EXEFLAG_TCTEXT));
|
| 943 |
fit->FixOriginalName();
|
943 |
fit->FixOriginalName();
|
| 944 |
CLog::logf(CLog::Log_Install, 2, "Adjusting text file, %s => %s", fit->getNameDirectory(this).c_str(), (newname + "." + fit->fileExt()).c_str());
|
944 |
CLog::logf(CLog::Log_Install, 2, L"Adjusting text file, %s => %s", fit->getNameDirectory(this).c_str(), (newname + "." + fit->fileExt()).c_str());
|
| 945 |
fit->setName(newname + "." + fit->fileExt());
|
945 |
fit->setName(newname + "." + fit->fileExt());
|
| 946 |
|
946 |
|
| 947 |
++starttext;
|
947 |
++starttext;
|
| 948 |
}
|
948 |
}
|
| 949 |
}
|
949 |
}
|
| Line 957... |
Line 957... |
| 957 |
else if ( (fit->GetFileType() == FILETYPE_EXTRA) && (fit->dir().left(7).lower() == L"Extras/") )
|
957 |
else if ( (fit->GetFileType() == FILETYPE_EXTRA) && (fit->dir().left(7).lower() == L"Extras/") )
|
| 958 |
bEnable = true;
|
958 |
bEnable = true;
|
| 959 |
else if ( (IsPatch()) && (fit->GetFileType() == FILETYPE_MOD) && (!fit->IsFakePatch()) )
|
959 |
else if ( (IsPatch()) && (fit->GetFileType() == FILETYPE_MOD) && (!fit->IsFakePatch()) )
|
| 960 |
bEnable = true;
|
960 |
bEnable = true;
|
| 961 |
|
961 |
|
| 962 |
if ( bEnable ) CLog::logf(CLog::Log_Install, 3, "Filetype(%d) is always enabled, setting enabled flag", fit->GetFileType());
|
962 |
if ( bEnable ) CLog::logf(CLog::Log_Install, 3, L"Filetype(%d) is always enabled, setting enabled flag", fit->GetFileType());
|
| 963 |
}
|
963 |
}
|
| 964 |
|
964 |
|
| 965 |
return bEnable;
|
965 |
return bEnable;
|
| 966 |
}
|
966 |
}
|
| 967 |
|
967 |
|
| Line 1047... |
Line 1047... |
| 1047 |
pFile->setFullDir ( filename + L"PluginManager/Disabled/" + pFile->getDirectory(this) );
|
1047 |
pFile->setFullDir ( filename + L"PluginManager/Disabled/" + pFile->getDirectory(this) );
|
| 1048 |
}
|
1048 |
}
|
| 1049 |
pFile->SetDisabled(true);
|
1049 |
pFile->SetDisabled(true);
|
| 1050 |
}
|
1050 |
}
|
| 1051 |
|
1051 |
|
| 1052 |
CLog::logf(CLog::Log_Install, 2, "Adjusting the file pointer to correct install destintation, %s", pFile->filePointer().c_str());
|
1052 |
CLog::logf(CLog::Log_Install, 2, L"Adjusting the file pointer to correct install destintation, %s", pFile->filePointer().c_str());
|
| 1053 |
|
1053 |
|
| 1054 |
return filename;
|
1054 |
return filename;
|
| 1055 |
}
|
1055 |
}
|
| 1056 |
|
1056 |
|
| 1057 |
C_File *CBaseFile::_install_checkFile(C_File *pFile, Utils::WStringList *errorStr, bool *bDoFile, CLinkList<C_File> *pFileList)
|
1057 |
C_File *CBaseFile::_install_checkFile(C_File *pFile, Utils::WStringList *errorStr, bool *bDoFile, CLinkList<C_File> *pFileList)
|
| Line 1083... |
Line 1083... |
| 1083 |
Utils::WString lastDir = CDirIO(dir).topDir().lower();
|
1083 |
Utils::WString lastDir = CDirIO(dir).topDir().lower();
|
| 1084 |
|
1084 |
|
| 1085 |
// if its disabled, rename it so its enabled
|
1085 |
// if its disabled, rename it so its enabled
|
| 1086 |
if ( ((pCheckFile->IsDisabled()) || (lastDir == L"disabled") || (dir.lower().contains(L"/disabled/"))) && (bEnabled) )
|
1086 |
if ( ((pCheckFile->IsDisabled()) || (lastDir == L"disabled") || (dir.lower().contains(L"/disabled/"))) && (bEnabled) )
|
| 1087 |
{
|
1087 |
{
|
| 1088 |
CLog::logf(CLog::Log_Install, 2, "Existing file, %s, is disabled, re-enabling it", pCheckFile->filePointer().c_str());
|
1088 |
CLog::logf(CLog::Log_Install, 2, L"Existing file, %s, is disabled, re-enabling it", pCheckFile->filePointer().c_str());
|
| 1089 |
// first check if the directory exists
|
1089 |
// first check if the directory exists
|
| 1090 |
if ( pCheckFile->isInMod() ) {
|
1090 |
if ( pCheckFile->isInMod() ) {
|
| 1091 |
Utils::WString tofile = pCheckFile->filePointer().token(L"::", 2);
|
1091 |
Utils::WString tofile = pCheckFile->filePointer().token(L"::", 2);
|
| 1092 |
|
1092 |
|
| 1093 |
CCatFile tocat;
|
1093 |
CCatFile tocat;
|
| 1094 |
int err = tocat.open(fit->filePointer().token(L"::", 1), L"", CATREAD_CATDECRYPT, true);
|
1094 |
int err = tocat.open(fit->filePointer().token(L"::", 1), L"", CATREAD_CATDECRYPT, true);
|
| 1095 |
if ( (err == CATERR_NONE) || (err == CATERR_CREATED) ) {
|
1095 |
if ( (err == CATERR_NONE) || (err == CATERR_CREATED) ) {
|
| 1096 |
tocat.appendFile(pCheckFile->filePointer(), tofile);
|
1096 |
tocat.appendFile(pCheckFile->filePointer(), tofile);
|
| 1097 |
CLog::logf(CLog::Log_Install, 2, "Adding existing file into new mod File, %s => %s", fit->filePointer().token(L"::", 1).c_str(), tofile.c_str());
|
1097 |
CLog::logf(CLog::Log_Install, 2, L"Adding existing file into new mod File, %s => %s", fit->filePointer().token(L"::", 1).c_str(), tofile.c_str());
|
| 1098 |
}
|
1098 |
}
|
| 1099 |
|
1099 |
|
| 1100 |
CCatFile fromcat;
|
1100 |
CCatFile fromcat;
|
| 1101 |
err = fromcat.open(pCheckFile->filePointer().token(L"::", 1), L"", CATREAD_CATDECRYPT, false);
|
1101 |
err = fromcat.open(pCheckFile->filePointer().token(L"::", 1), L"", CATREAD_CATDECRYPT, false);
|
| 1102 |
if ( err == CATERR_NONE ) {
|
1102 |
if ( err == CATERR_NONE ) {
|
| 1103 |
fromcat.removeFile(tofile);
|
1103 |
fromcat.removeFile(tofile);
|
| 1104 |
CLog::logf(CLog::Log_Install, 2, "Removing file from existing mod, %s::%s", pCheckFile->filePointer().token(L"::", 1).c_str(), tofile.c_str());
|
1104 |
CLog::logf(CLog::Log_Install, 2, L"Removing file from existing mod, %s::%s", pCheckFile->filePointer().token(L"::", 1).c_str(), tofile.c_str());
|
| 1105 |
}
|
1105 |
}
|
| 1106 |
|
1106 |
|
| 1107 |
CLog::logf(CLog::Log_Install, 1, "Adjusting existing file name %s => %s", pCheckFile->filePointer().c_str(), fit->filePointer().c_str());
|
1107 |
CLog::logf(CLog::Log_Install, 1, L"Adjusting existing file name %s => %s", pCheckFile->filePointer().c_str(), fit->filePointer().c_str());
|
| 1108 |
pCheckFile->setFilename(fit->filePointer());
|
1108 |
pCheckFile->setFilename(fit->filePointer());
|
| 1109 |
CLog::logf(CLog::Log_Install, 2, "Adjusting In Mod setting, %s => %s", pCheckFile->getInMod().c_str(), fit->getInMod().c_str());
|
1109 |
CLog::logf(CLog::Log_Install, 2, L"Adjusting In Mod setting, %s => %s", pCheckFile->getInMod().c_str(), fit->getInMod().c_str());
|
| 1110 |
pCheckFile->setInMod(fit->getInMod());
|
1110 |
pCheckFile->setInMod(fit->getInMod());
|
| 1111 |
}
|
1111 |
}
|
| 1112 |
else {
|
1112 |
else {
|
| 1113 |
Utils::WString to = pCheckFile->getDirectory(this);
|
1113 |
Utils::WString to = pCheckFile->getDirectory(this);
|
| 1114 |
CDirIO Dir(sDestination);
|
1114 |
CDirIO Dir(sDestination);
|
| Line 1120... |
Line 1120... |
| 1120 |
if ( errorStr ) errorStr->pushBack(to, ERRORLOG(SPKINSTALL_CREATEDIRECTORY));
|
1120 |
if ( errorStr ) errorStr->pushBack(to, ERRORLOG(SPKINSTALL_CREATEDIRECTORY));
|
| 1121 |
}
|
1121 |
}
|
| 1122 |
|
1122 |
|
| 1123 |
Utils::WString destfile = sDestination + L"/" + pCheckFile->getNameDirectory(this);
|
1123 |
Utils::WString destfile = sDestination + L"/" + pCheckFile->getNameDirectory(this);
|
| 1124 |
if ( CFileIO::Exists(destfile) ) CFileIO::Remove(destfile);
|
1124 |
if ( CFileIO::Exists(destfile) ) CFileIO::Remove(destfile);
|
| 1125 |
CLog::logf(CLog::Log_Install, 1, "Adjusting existing filename, %s => %s", pCheckFile->filePointer().c_str(), destfile.c_str());
|
1125 |
CLog::logf(CLog::Log_Install, 1, L"Adjusting existing filename, %s => %s", pCheckFile->filePointer().c_str(), destfile.c_str());
|
| 1126 |
CFileIO::Rename(pCheckFile->filePointer(), destfile);
|
1126 |
CFileIO::Rename(pCheckFile->filePointer(), destfile);
|
| 1127 |
pCheckFile->setFilename (sDestination + L"/" + pCheckFile->getNameDirectory(this) );
|
1127 |
pCheckFile->setFilename (sDestination + L"/" + pCheckFile->getNameDirectory(this) );
|
| 1128 |
}
|
1128 |
}
|
| 1129 |
pCheckFile->SetDisabled(false);
|
1129 |
pCheckFile->SetDisabled(false);
|
| 1130 |
|
1130 |
|
| Line 1139... |
Line 1139... |
| 1139 |
_sLastError = sTo;
|
1139 |
_sLastError = sTo;
|
| 1140 |
if ( !sTo.contains(L"::"))
|
1140 |
if ( !sTo.contains(L"::"))
|
| 1141 |
{
|
1141 |
{
|
| 1142 |
if ( !Dir.exists(sTo) )
|
1142 |
if ( !Dir.exists(sTo) )
|
| 1143 |
{
|
1143 |
{
|
| 1144 |
CLog::logf(CLog::Log_Install, 2, "Creating directory to install file into, %s", sTo.c_str());
|
1144 |
CLog::logf(CLog::Log_Install, 2, L"Creating directory to install file into, %s", sTo.c_str());
|
| 1145 |
if ( !Dir.create(sTo) )
|
1145 |
if ( !Dir.create(sTo) )
|
| 1146 |
{
|
1146 |
{
|
| 1147 |
if ( errorStr )
|
1147 |
if ( errorStr )
|
| 1148 |
errorStr->pushBack(sTo, ERRORLOG(SPKINSTALL_CREATEDIRECTORY_FAIL));
|
1148 |
errorStr->pushBack(sTo, ERRORLOG(SPKINSTALL_CREATEDIRECTORY_FAIL));
|
| 1149 |
return false;
|
1149 |
return false;
|
| Line 1151... |
Line 1151... |
| 1151 |
if ( errorStr )
|
1151 |
if ( errorStr )
|
| 1152 |
errorStr->pushBack(sTo, ERRORLOG(SPKINSTALL_CREATEDIRECTORY));
|
1152 |
errorStr->pushBack(sTo, ERRORLOG(SPKINSTALL_CREATEDIRECTORY));
|
| 1153 |
}
|
1153 |
}
|
| 1154 |
}
|
1154 |
}
|
| 1155 |
else {
|
1155 |
else {
|
| 1156 |
CLog::logf(CLog::Log_Install, 2, "Adjusting file extension for file in mod, %s => %s", pFile->filePointer().c_str(), CCatFile::PckChangeExtension(pFile->filePointer()).c_str());
|
1156 |
CLog::logf(CLog::Log_Install, 2, L"Adjusting file extension for file in mod, %s => %s", pFile->filePointer().c_str(), CCatFile::PckChangeExtension(pFile->filePointer()).c_str());
|
| 1157 |
pFile->setFilename(CCatFile::PckChangeExtension(pFile->filePointer()));
|
1157 |
pFile->setFilename(CCatFile::PckChangeExtension(pFile->filePointer()));
|
| 1158 |
}
|
1158 |
}
|
| 1159 |
|
1159 |
|
| 1160 |
return true;
|
1160 |
return true;
|
| 1161 |
}
|
1161 |
}
|
| Line 1212... |
Line 1212... |
| 1212 |
for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
|
1212 |
for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
|
| 1213 |
{
|
1213 |
{
|
| 1214 |
C_File *fit = node->Data();
|
1214 |
C_File *fit = node->Data();
|
| 1215 |
|
1215 |
|
| 1216 |
// start the install process, check if we need to the file enabled or disabled
|
1216 |
// start the install process, check if we need to the file enabled or disabled
|
| 1217 |
CLog::logf(CLog::Log_Install, 1, "Preparing to install file: %s", fit->getNameDirectory(this).c_str());
|
1217 |
CLog::logf(CLog::Log_Install, 1, L"Preparing to install file: %s", fit->getNameDirectory(this).c_str());
|
| 1218 |
bool fileEnabled = _install_setEnabled(enabled, fit);
|
1218 |
bool fileEnabled = _install_setEnabled(enabled, fit);
|
| 1219 |
|
1219 |
|
| 1220 |
// check if the file is for the correct game version
|
1220 |
// check if the file is for the correct game version
|
| 1221 |
if (!fit->isForGame(packages->GetGame()))
|
1221 |
if (!fit->isForGame(packages->GetGame()))
|
| 1222 |
{
|
1222 |
{
|
| 1223 |
CLog::logf(CLog::Log_Install, 1, "File didn't match game version, skipping, %d != %d", fit->game(), packages->GetGame());
|
1223 |
CLog::logf(CLog::Log_Install, 1, L"File didn't match game version, skipping, %d != %d", fit->game(), packages->GetGame());
|
| 1224 |
continue;
|
1224 |
continue;
|
| 1225 |
}
|
1225 |
}
|
| 1226 |
|
1226 |
|
| 1227 |
// update the progress display to show we are processing this file
|
1227 |
// update the progress display to show we are processing this file
|
| 1228 |
if ( progress ) {
|
1228 |
if ( progress ) {
|
| Line 1678... |
Line 1678... |
| 1678 |
unsigned char *readData = 0;
|
1678 |
unsigned char *readData = 0;
|
| 1679 |
try {
|
1679 |
try {
|
| 1680 |
readData = new unsigned char[m_SHeader.lValueCompressSize];
|
1680 |
readData = new unsigned char[m_SHeader.lValueCompressSize];
|
| 1681 |
}
|
1681 |
}
|
| 1682 |
catch (std::exception &e) {
|
1682 |
catch (std::exception &e) {
|
| 1683 |
CLog::logf(CLog::Log_IO, 2, "CBaseFile::_read_Header() unable to malloc [header], %d (%s)", m_SHeader.lValueCompressSize, e.what());
|
1683 |
CLog::logf(CLog::Log_IO, 2, L"CBaseFile::_read_Header() unable to malloc [header], %d (%hs)", m_SHeader.lValueCompressSize, e.what());
|
| 1684 |
return -1;
|
1684 |
return -1;
|
| 1685 |
}
|
1685 |
}
|
| 1686 |
|
1686 |
|
| 1687 |
if (!readData)
|
1687 |
if (!readData)
|
| 1688 |
return -1;
|
1688 |
return -1;
|
| Line 1716... |
Line 1716... |
| 1716 |
}
|
1716 |
}
|
| 1717 |
doneLen = uncomprLen;
|
1717 |
doneLen = uncomprLen;
|
| 1718 |
delete []uncompr;
|
1718 |
delete []uncompr;
|
| 1719 |
}
|
1719 |
}
|
| 1720 |
catch (std::exception &e) {
|
1720 |
catch (std::exception &e) {
|
| 1721 |
CLog::logf(CLog::Log_IO, 2, "CBaseFile::_read_Header() unable to malloc [uncompr], %d (%s)", uncomprLen, e.what());
|
1721 |
CLog::logf(CLog::Log_IO, 2, L"CBaseFile::_read_Header() unable to malloc [uncompr], %d (%hs)", uncomprLen, e.what());
|
| 1722 |
delete []readData;
|
1722 |
delete []readData;
|
| 1723 |
return -1;
|
1723 |
return -1;
|
| 1724 |
}
|
1724 |
}
|
| 1725 |
}
|
1725 |
}
|
| 1726 |
else if ( m_SHeader.iValueCompression == SPKCOMPRESS_7ZIP ) {
|
1726 |
else if ( m_SHeader.iValueCompression == SPKCOMPRESS_7ZIP ) {
|
| Line 1768... |
Line 1768... |
| 1768 |
unsigned char *readData;
|
1768 |
unsigned char *readData;
|
| 1769 |
try {
|
1769 |
try {
|
| 1770 |
readData = new unsigned char[m_SHeader2.lSize];
|
1770 |
readData = new unsigned char[m_SHeader2.lSize];
|
| 1771 |
}
|
1771 |
}
|
| 1772 |
catch (std::exception &e) {
|
1772 |
catch (std::exception &e) {
|
| 1773 |
CLog::logf(CLog::Log_IO, 2, "CBaseFile::_read_FileHeader() unable to malloc [header], %d (%s)", m_SHeader2.lSize, e.what());
|
1773 |
CLog::logf(CLog::Log_IO, 2, L"CBaseFile::_read_FileHeader() unable to malloc [header], %d (%hs)", m_SHeader2.lSize, e.what());
|
| 1774 |
return -1;
|
1774 |
return -1;
|
| 1775 |
}
|
1775 |
}
|
| 1776 |
|
1776 |
|
| 1777 |
unsigned char size[4];
|
1777 |
unsigned char size[4];
|
| 1778 |
File.read(size, 4);
|
1778 |
File.read(size, 4);
|
| Line 1805... |
Line 1805... |
| 1805 |
//#pragma warning(enable:4244)
|
1805 |
//#pragma warning(enable:4244)
|
| 1806 |
}
|
1806 |
}
|
| 1807 |
delete[] uncompr;
|
1807 |
delete[] uncompr;
|
| 1808 |
}
|
1808 |
}
|
| 1809 |
catch (std::exception &e) {
|
1809 |
catch (std::exception &e) {
|
| 1810 |
CLog::logf(CLog::Log_IO, 2, "CBaseFile::_read_FileHeader() unable to malloc [uncompr], %d (%s)", uncomprLen, e.what());
|
1810 |
CLog::logf(CLog::Log_IO, 2, L"CBaseFile::_read_FileHeader() unable to malloc [uncompr], %d (%hs)", uncomprLen, e.what());
|
| 1811 |
delete []readData;
|
1811 |
delete []readData;
|
| 1812 |
return -1;
|
1812 |
return -1;
|
| 1813 |
}
|
1813 |
}
|
| 1814 |
|
1814 |
|
| 1815 |
}
|
1815 |
}
|