emscripten icon indicating copy to clipboard operation
emscripten copied to clipboard

throw a EExists error when calling emscripten_wget twice with the same name

Open legend-chen opened this issue 8 years ago • 3 comments

i dont know how to deal with this situation, but the api reference says that the file would be overwriten.

the following is simple piece of the code which is much like the official one.

#include <stdio.h> #include <ctype.h> #include <string.h> #include <assert.h> #include <stdlib.h> #include <emscripten.h>

int main() { const char * file = "./test.txt"; unsigned char* buffer; emscripten_wget(file , file); emscripten_wget(file , file);

FILE * f = fopen(file, "r");
fseek(f, 0, SEEK_END);
int size = ftell(f);
printf("size: %d\n", size);

buffer = (unsigned char*)malloc(sizeof(unsigned char) * (size+1)); 
rewind(f);
fread(buffer, 1, size, f);
fclose(f);
buffer[size] = 0;
int result = 0;

printf("%s\n", buffer);
return 0;

}

legend-chen avatar Aug 13 '18 10:08 legend-chen

https://github.com/kripken/emscripten/pull/4617

legend-chen avatar Aug 13 '18 10:08 legend-chen

What options did you compile that with?

kripken avatar Aug 14 '18 18:08 kripken

emcc text_wget.cpp -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 -s ASSERTIONS=1 -s EMTERPRETIFY_FILE=emtepret.bin -O2 -g2 -o text_wget.html

I don't think it is necessary to throw a error in that case which a warn would generally happened. However, according to #4617 , there is no need to open this issue further.

legend-chen avatar Aug 16 '18 05:08 legend-chen