The test suite has working examples of those APIs, for example
test_emscripten_fs_api uses emscripten_async_wget.

On Thu, Aug 18, 2016 at 11:49 AM, Sander Boer <[email protected]> wrote:

> Hi,
>
> for the life of me I cannot get the emscripten_wget of
> emscripten_async_wget to work.
> I want to use wget to dl a json file I want to parse later, for this I
> want to set up a temp file, dl the date, parse and destroy.
>
> However, it complains that the "file exists" of the FS in case of mounting
> the MEMFS, or the size is 0 in case of FS.createDataFile..
>
> Help is appreciated.
>
>
> this is a snippet of the code I have:
> void Test2(){
>
>   EM_ASM(
>       // FS.mkdir('/');
>       // FS.mount(MEMFS, {}, '/');
>       FS.createDataFile("/", "file.txt", "File contents here", true, true);
>          );
>
>   char *path = "/file.txt";
>
>   printf("Downloading...\n");
>   myurl="http://test.site/json";;
>
>   // emscripten_async_wget(myurl.c_str(), path, onLoadWget, onErrorWget);
>   emscripten_wget(myurl.c_str(), path );
>
>   printf("Download completed\n");
>
>   FILE *json;
>   json=fopen(path,"r");
>   if(json==NULL) {
>     printf("ERROR: Can't open file!\n");
>     exit (2);
>   }else{
>     long size = ftell (json);
>     printf("size: %ld\n", size);
>     fputs ("fopen example\n", json);
>     fclose ( json );
>     }
>   }
>
> void onLoadWget(const char* fname){
>   printf("wget loaded: %s\n", fname);
>  }
>
> void onErrorWget(const char* fname){
>   printf("wget failed: %s", fname);
> }
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to