| 117 |
|
copyPackageFolders(macTable,"mac_only",modDir,bslExist); |
| 118 |
|
} |
| 119 |
|
|
| 120 |
< |
QFile *modInfo = new QFile(modDir+"Mod_Info.cfg"); |
| 120 |
> |
QFile modInfo(modDir+"Mod_Info.cfg"); |
| 121 |
|
|
| 122 |
< |
if (!modInfo->open(QIODevice::WriteOnly | QIODevice::Text)){ //open to write |
| 123 |
< |
Util::showErrorPopUp("Couldn't create Mod_Info.cfg file."); |
| 124 |
< |
myLogger->writeString("Couldn't create Mod_Info.cfg file when creating AE Package."); |
| 122 |
> |
if (!modInfo.open(QIODevice::WriteOnly | QIODevice::Text)){ //open to write |
| 123 |
> |
UtilVago::showAndLogErrorPopUp(this->myLogger, "Couldn't create Mod_Info.cfg file when creating AE Package."); |
| 124 |
|
return; |
| 125 |
|
} |
| 126 |
|
|
| 127 |
< |
QTextStream *modWriteStream = new QTextStream (modInfo); |
| 128 |
< |
*modWriteStream << "AEInstallVersion -> "+aeVersion+"\n"; |
| 129 |
< |
*modWriteStream << "NameOfMod -> "+modName+"\n"; |
| 130 |
< |
*modWriteStream << "ModVersion -> "+version+"\n"; |
| 131 |
< |
*modWriteStream << "Creator -> "+authors+"\n"; |
| 132 |
< |
*modWriteStream << "Readme -> "+description.replace("\n"," \\n ")+"\n"; |
| 127 |
> |
QTextStream modWriteStream(&modInfo); |
| 128 |
> |
modWriteStream << "AEInstallVersion -> "+aeVersion+"\n"; |
| 129 |
> |
modWriteStream << "NameOfMod -> "+modName+"\n"; |
| 130 |
> |
modWriteStream << "ModVersion -> "+version+"\n"; |
| 131 |
> |
modWriteStream << "Creator -> "+authors+"\n"; |
| 132 |
> |
modWriteStream << "Readme -> "+description.replace("\n"," \\n ")+"\n"; |
| 133 |
|
if(!incompatiblePackages.isEmpty()){ |
| 134 |
< |
*modWriteStream << "IncompatibleWith -> "+incompatiblePackages+"\n"; |
| 134 |
> |
modWriteStream << "IncompatibleWith -> "+incompatiblePackages+"\n"; |
| 135 |
|
} |
| 136 |
|
if(!dependentPackages.isEmpty()){ |
| 137 |
< |
*modWriteStream << "DependsOn -> "+dependentPackages+"\n"; |
| 137 |
> |
modWriteStream << "DependsOn -> "+dependentPackages+"\n"; |
| 138 |
|
} |
| 139 |
|
|
| 140 |
|
if(bslExist){ |
| 141 |
|
if(bslReplace){ |
| 142 |
< |
*modWriteStream << "HasBsl -> Yes\n"; |
| 142 |
> |
modWriteStream << "HasBsl -> Yes\n"; |
| 143 |
|
} |
| 144 |
|
else{ |
| 145 |
< |
*modWriteStream << "HasBsl -> Addon\n"; |
| 145 |
> |
modWriteStream << "HasBsl -> Addon\n"; |
| 146 |
|
} |
| 147 |
|
} |
| 148 |
|
|
| 149 |
|
if(!unlockLevels.isEmpty()){ |
| 150 |
< |
*modWriteStream << "UnlockLevel -> "+unlockLevels+"\n"; |
| 150 |
> |
modWriteStream << "UnlockLevel -> "+unlockLevels+"\n"; |
| 151 |
|
} |
| 152 |
|
|
| 153 |
< |
*modWriteStream << "Vago -> "+GlobalVars::AppVersion; |
| 153 |
> |
modWriteStream << "Vago -> "+GlobalVars::AppVersion; |
| 154 |
|
|
| 155 |
< |
delete modWriteStream; //it auto closes the files/streams |
| 157 |
< |
delete modInfo; |
| 155 |
> |
modInfo.close(); |
| 156 |
|
|
| 159 |
– |
//Create zipped package using PKZIP 2.0 (http://osdab.42cows.org/snippets/zip.php?mode=advanced) |
| 157 |
|
if(createZip){ |
| 158 |
< |
Zip uz; |
| 159 |
< |
|
| 160 |
< |
Zip::ErrorCode ec = uz.createArchive(this->packagesLocation+"/"+packageName+".zip"); |
| 164 |
< |
checkForZipError(ec); |
| 165 |
< |
|
| 166 |
< |
ec=uz.addDirectory(modDir); |
| 167 |
< |
checkForZipError(ec); |
| 168 |
< |
|
| 169 |
< |
ec = uz.closeArchive(); |
| 170 |
< |
checkForZipError(ec); |
| 158 |
> |
if(!JlCompress::compressDir(this->packagesLocation+"/"+packageName+".zip", modDir)){ |
| 159 |
> |
UtilVago::showAndLogErrorPopUp(this->myLogger, "An error occurred while zipping the package."); |
| 160 |
> |
} |
| 161 |
|
} |
| 162 |
|
|
| 163 |
|
if(openFolder){ |
| 194 |
|
} |
| 195 |
|
} |
| 196 |
|
QDir().mkpath(path); //create path if doesn't exist |
| 197 |
< |
if(!Util::copyDir(sourceFolder,path+Util::cutName(sourceFolder),false)){//copy contents (creates dest destination automatically if not exists yet) |
| 208 |
< |
QString errorString="An error occurred while copying the folder/files to the package folder: \n" |
| 209 |
< |
"Copying from "+sourceFolder+"\n to "+path+Util::cutName(sourceFolder); |
| 210 |
< |
Util::showErrorLogPopUp(errorString); |
| 211 |
< |
this->myLogger->writeString(errorString); |
| 212 |
< |
} |
| 213 |
< |
} |
| 214 |
< |
} |
| 197 |
> |
if(!Util::copyDir(sourceFolder,path,false)){//copy contents (creates dest destination automatically if not exists yet) |
| 198 |
|
|
| 199 |
< |
/** |
| 200 |
< |
Convenience function for checking for zipping errors |
| 201 |
< |
*/ |
| 219 |
< |
void PackageWizard::checkForZipError(Zip::ErrorCode ec){ |
| 220 |
< |
if (ec != Zip::Ok){ |
| 221 |
< |
const QString error="Error found while zipping the package. Error number = "+QString::number(ec); |
| 222 |
< |
Util::showErrorPopUp(error); |
| 223 |
< |
this->myLogger->writeString(error); |
| 199 |
> |
UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "An error occurred while copying the folder/files to the package folder: \n" |
| 200 |
> |
"Copying from "+sourceFolder+"\n to "+path); |
| 201 |
> |
} |
| 202 |
|
} |
| 203 |
|
} |