|
|
@ -59,15 +59,28 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
|
|
class plResDownloadStream : public plZlibStream |
|
|
|
class plResDownloadStream : public plZlibStream |
|
|
|
{ |
|
|
|
{ |
|
|
|
plOperationProgress* fProgress; |
|
|
|
plOperationProgress* fProgress; |
|
|
|
|
|
|
|
char* fFilename; |
|
|
|
bool fIsZipped; |
|
|
|
bool fIsZipped; |
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
public: |
|
|
|
plResDownloadStream(plOperationProgress* prog, const wchar_t* reqFile) |
|
|
|
plResDownloadStream(plOperationProgress* prog, const wchar_t* reqFile) |
|
|
|
: fProgress(prog)
|
|
|
|
: fProgress(prog), fFilename(nil) |
|
|
|
{
|
|
|
|
{
|
|
|
|
fIsZipped = wcscmp(plFileUtils::GetFileExt(reqFile), L"gz") == 0; |
|
|
|
fIsZipped = wcscmp(plFileUtils::GetFileExt(reqFile), L"gz") == 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
~plResDownloadStream() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (fFilename) |
|
|
|
|
|
|
|
delete[] fFilename; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hsBool Open(const char* filename, const char* mode) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fFilename = hsStrcpy(filename); |
|
|
|
|
|
|
|
return plZlibStream::Open(filename, mode); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uint32_t Write(uint32_t count, const void* buf) |
|
|
|
uint32_t Write(uint32_t count, const void* buf) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fProgress->Increment((float)count); |
|
|
|
fProgress->Increment((float)count); |
|
|
@ -78,6 +91,7 @@ public: |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool IsZipped() const { return fIsZipped; } |
|
|
|
bool IsZipped() const { return fIsZipped; } |
|
|
|
|
|
|
|
void Unlink() const { plFileUtils::RemoveFile(fFilename); } |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
@ -93,7 +107,6 @@ static void FileDownloaded( |
|
|
|
if (((plResDownloadStream*)writer)->IsZipped()) |
|
|
|
if (((plResDownloadStream*)writer)->IsZipped()) |
|
|
|
plFileUtils::StripExt(name); // Kill off .gz
|
|
|
|
plFileUtils::StripExt(name); // Kill off .gz
|
|
|
|
writer->Close(); |
|
|
|
writer->Close(); |
|
|
|
delete writer; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (result) |
|
|
|
switch (result) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -107,6 +120,7 @@ static void FileDownloaded( |
|
|
|
// Continue down the warpath
|
|
|
|
// Continue down the warpath
|
|
|
|
patcher->IssueRequest(); |
|
|
|
patcher->IssueRequest(); |
|
|
|
delete[] name; |
|
|
|
delete[] name; |
|
|
|
|
|
|
|
delete writer; |
|
|
|
return; |
|
|
|
return; |
|
|
|
case kNetErrFileNotFound: |
|
|
|
case kNetErrFileNotFound: |
|
|
|
PatcherLog(kError, " Download Failed: %s not found", name); |
|
|
|
PatcherLog(kError, " Download Failed: %s not found", name); |
|
|
@ -119,8 +133,10 @@ static void FileDownloaded( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Failure case
|
|
|
|
// Failure case
|
|
|
|
|
|
|
|
((plResDownloadStream*)writer)->Unlink(); |
|
|
|
patcher->Finish(false); |
|
|
|
patcher->Finish(false); |
|
|
|
delete[] name; |
|
|
|
delete[] name; |
|
|
|
|
|
|
|
delete writer; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void ManifestDownloaded( |
|
|
|
static void ManifestDownloaded( |
|
|
|