Do binary writes instead.

This commit is contained in:
David Anderson 2009-03-01 01:18:09 -05:00
parent eb25650e26
commit f104438802
3 changed files with 18 additions and 3 deletions

View File

@ -38,6 +38,7 @@
#define USTATE_FOLDERS 1
#define USTATE_CHANGED 2
#define USTATE_CHANGE_FILE 3
#define USTATE_ERRORS 4
using namespace SourceMod;
@ -75,6 +76,10 @@ SMCResult UpdateReader::ReadSMC_NewSection(const SMCStates *states, const char *
{
ustate = USTATE_CHANGED;
}
else if (strcmp(name, "Errors") == 0)
{
ustate = USTATE_ERRORS;
}
else
{
ignoreLevel++;
@ -128,6 +133,14 @@ SMCResult UpdateReader::ReadSMC_KeyValue(const SMCStates *states,
}
break;
}
case USTATE_ERRORS:
{
if (strcmp(key, "error") == 0)
{
AddUpdateError("%s", value);
}
break;
}
case USTATE_FOLDERS:
{
HandleFolder(value);
@ -150,6 +163,7 @@ SMCResult UpdateReader::ReadSMC_LeavingSection(const SMCStates *states)
{
case USTATE_FOLDERS:
case USTATE_CHANGED:
case USTATE_ERRORS:
{
ustate = USTATE_NONE;
break;
@ -220,6 +234,7 @@ void UpdateReader::HandleFile()
UpdatePart *part = new UpdatePart;
part->data = (char*)malloc(mdl.GetSize());
memcpy(part->data, mdl.GetBuffer(), mdl.GetSize());
part->file = strdup(curfile.c_str());
part->length = mdl.GetSize();
LinkPart(part);
@ -241,7 +256,7 @@ static bool md5_file(const char *file, char checksum[33])
long length;
void *fdata;
if ((fp = fopen(file, "rt")) == NULL)
if ((fp = fopen(file, "rb")) == NULL)
{
return false;
}

View File

@ -153,7 +153,7 @@ static void PumpUpdate(void *data)
else
{
smutils->BuildPath(Path_SM, path, sizeof(path), "gamedata/%s", part->file);
FILE *fp = fopen(path, "wt");
FILE *fp = fopen(path, "wb");
if (fp == NULL)
{
AddUpdateError("Could not open %s for writing", path);

View File

@ -121,7 +121,7 @@
<Tool
Name="VCCLCompilerTool"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..;..\sdk;..\..;..\..\sourcepawn;&quot;$(HL2SDKOB)\public&quot;;&quot;$(HL2SDKOB)\public\engine&quot;;&quot;$(HL2SDKOB)\public\game\server&quot;;&quot;$(HL2SDKOB)\public\tier0&quot;;&quot;$(HL2SDKOB)\public\tier1&quot;;&quot;$(MMSOURCE17)\core&quot;;&quot;$(MMSOURCE17)\core\sourcehook&quot;"
AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions;&quot;$(MMSOURCE17)\core\sourcehook&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;ORANGEBOX_BUILD;_CRT_NONSTDC_NO_DEPRECATE"
RuntimeLibrary="0"
EnableEnhancedInstructionSet="1"