Bug 518004. Workaround a link problem on 64-bit linux with the test plugin by removing use of <fstream>. r=smaug

--HG--
extra : rebase_source : af6a48cca2eb0807ab30c2f6e63a5b2b4bf52c06
This commit is contained in:
Jonathan Griffin 2009-09-24 15:23:35 -07:00
parent eba22846fb
commit 5b8a3fa575

View File

@ -40,7 +40,6 @@
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
@ -367,9 +366,12 @@ NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char*
return NPERR_OUT_OF_MEMORY_ERROR;
instanceData->npp = instance;
instanceData->streamMode = NP_ASFILEONLY;
instanceData->testFunction = FUNCTION_NONE;
instanceData->streamChunkSize = 1024;
instanceData->streamBuf = NULL;
instanceData->streamBufSize = 0;
instanceData->fileBuf = NULL;
instanceData->fileBufSize = 0;
instanceData->testrange = NULL;
instanceData->hasWidget = false;
memset(&instanceData->window, 0, sizeof(instanceData->window));
@ -539,6 +541,9 @@ NPP_Destroy(NPP instance, NPSavedData** save)
if (instanceData->streamBuf) {
free(instanceData->streamBuf);
}
if (instanceData->fileBuf) {
free(instanceData->fileBuf);
}
TestRange* currentrange = instanceData->testrange;
TestRange* nextrange;
@ -602,8 +607,8 @@ NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason)
}
}
if (instanceData->frame.length() > 0 &&
instanceData->testFunction != FUNCTION_NPP_GETURLNOTIFY &&
instanceData->testFunction != FUNCTION_NPP_POSTURL) {
instanceData->testFunction != FUNCTION_NPP_GETURLNOTIFY &&
instanceData->testFunction != FUNCTION_NPP_POSTURL) {
sendBufferToFrame(instance);
}
if (instanceData->testFunction == FUNCTION_NPP_POSTURL) {
@ -698,25 +703,28 @@ void
NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
{
printf("NPP_StreamAsFile, file=%s\n", fname);
ifstream::pos_type size;
size_t size;
InstanceData* instanceData = (InstanceData*)(instance->pdata);
if (!fname)
return;
ifstream file (fname, ios::in|ios::binary|ios::ate);
if (file.is_open())
{
size = file.tellg();
FILE *file = fopen(fname, "rb");
if (file) {
fseek(file, 0, SEEK_END);
size = ftell(file);
instanceData->fileBuf = malloc((int32_t)size + 1);
char* buf = reinterpret_cast<char *>(instanceData->fileBuf);
file.seekg (0, ios::beg);
file.read (buf, size);
file.close();
fseek(file, 0, SEEK_SET);
fread(instanceData->fileBuf, 1, size, file);
fclose(file);
buf[size] = '\0';
instanceData->fileBufSize = (int32_t)size;
}
else {
printf("Unable to open file\n");
}
}
void