Initialize nacl_io, removes SDL_NaClMount/Umount
authorGabriel Jacobo <gabomdq@gmail.com>
Fri, 20 Jun 2014 10:59:51 -0300
changeset 88770d691f3734ac
parent 8876 60edb019f0fe
child 8878 f7ba2119fd91
Initialize nacl_io, removes SDL_NaClMount/Umount

It's just easier to use nacl_io's mount/umount directly.
README-nacl.txt
build-scripts/naclbuild.sh
include/SDL_system.h
src/main/nacl/SDL_nacl_main.c
     1.1 --- a/README-nacl.txt	Thu Jun 19 00:40:09 2014 -0400
     1.2 +++ b/README-nacl.txt	Fri Jun 20 10:59:51 2014 -0300
     1.3 @@ -60,18 +60,17 @@
     1.4  RWops and nacl_io
     1.5  ================================================================================
     1.6  
     1.7 -SDL_RWops work transparently with nacl_io. Two functions are provided to control
     1.8 -mount points:
     1.9 +SDL_RWops work transparently with nacl_io. Two functions control the mount points:
    1.10      
    1.11 -    int SDL_NaClMount(const char* source, const char* target, 
    1.12 +    int mount(const char* source, const char* target, 
    1.13                        const char* filesystemtype, 
    1.14                        unsigned long mountflags, const void *data);
    1.15 -    int SDL_NaClUmount(const char *target);
    1.16 +    int umount(const char *target);
    1.17      
    1.18      For convenience, SDL will by default mount an httpfs tree at / before calling 
    1.19  the app's main function. Such setting can be overridden by calling:
    1.20      
    1.21 -    SDL_NaClUmount("/");
    1.22 +    umount("/");
    1.23  
    1.24  And then mounting a different filesystem at /
    1.25  
    1.26 @@ -85,6 +84,17 @@
    1.27  For more information on how nacl_io and mount points work, see:
    1.28      
    1.29      https://developer.chrome.com/native-client/devguide/coding/nacl_io
    1.30 +    https://src.chromium.org/chrome/trunk/src/native_client_sdk/src/libraries/nacl_io/nacl_io.h
    1.31 +
    1.32 +To be able to save into the directory "/save/" (like backup of game) :
    1.33 +
    1.34 +    mount("", "/save", "html5fs", 0, "type=PERSISTENT");
    1.35 +
    1.36 +And add to manifest.json :
    1.37 +
    1.38 +  "permissions": [
    1.39 +     "unlimitedStorage"
    1.40 +  ]
    1.41  
    1.42  ================================================================================
    1.43  TODO - Known Issues
     2.1 --- a/build-scripts/naclbuild.sh	Thu Jun 19 00:40:09 2014 -0400
     2.2 +++ b/build-scripts/naclbuild.sh	Fri Jun 20 10:59:51 2014 -0300
     2.3 @@ -1,6 +1,6 @@
     2.4  #!/bin/bash
     2.5  if [ -z "$1" ] && [ -z "$NACL_SDK_ROOT" ]; then
     2.6 -    echo "Usage: ./naclbuild ~/nacl/pepper_33"
     2.7 +    echo "Usage: ./naclbuild ~/nacl/pepper_35"
     2.8      echo "This will build SDL for Native Client, and testgles2.c as a demo"
     2.9      echo "You can set env vars CC, AR, LD and RANLIB to override the default PNaCl toolchain used"
    2.10      echo "You can set env var SOURCES to select a different source file than testgles2.c"
     3.1 --- a/include/SDL_system.h	Thu Jun 19 00:40:09 2014 -0400
     3.2 +++ b/include/SDL_system.h	Fri Jun 20 10:59:51 2014 -0300
     3.3 @@ -179,23 +179,6 @@
     3.4  
     3.5  #endif /* __WINRT__ */
     3.6  
     3.7 -#ifdef __NACL__
     3.8 -
     3.9 -/**
    3.10 - *  \name Mount/umount functions
    3.11 - *
    3.12 - *  Required for RWOps on Native Client
    3.13 - */
    3.14 -/* @{ */
    3.15 -extern DECLSPEC int SDLCALL SDL_NaClMount(const char* source, const char* target, 
    3.16 -                                        const char* filesystemtype, 
    3.17 -                                        unsigned long mountflags, const void *data);
    3.18 -
    3.19 -extern DECLSPEC int SDLCALL SDL_NaClUmount(const char *target);
    3.20 -
    3.21 -#endif /* __NACL__ */
    3.22 -
    3.23 -
    3.24  /* Ends C function definitions when using C++ */
    3.25  #ifdef __cplusplus
    3.26  }
     4.1 --- a/src/main/nacl/SDL_nacl_main.c	Thu Jun 19 00:40:09 2014 -0400
     4.2 +++ b/src/main/nacl/SDL_nacl_main.c	Fri Jun 20 10:59:51 2014 -0300
     4.3 @@ -24,11 +24,11 @@
     4.4  
     4.5  /* Include the SDL main definition header */
     4.6  #include "SDL_main.h"
     4.7 -#include "SDL_system.h"
     4.8  
     4.9  #include "ppapi_simple/ps_main.h"
    4.10  #include "ppapi_simple/ps_event.h"
    4.11  #include "ppapi_simple/ps_interface.h"
    4.12 +#include "nacl_io/nacl_io.h"
    4.13  
    4.14  extern void NACL_SetScreenResolution(int width, int height, Uint32 format);
    4.15  
    4.16 @@ -69,8 +69,10 @@
    4.17       * apps can override this by unmounting / 
    4.18       * and remounting with the desired configuration
    4.19       */
    4.20 -    SDL_NaClUmount("/");
    4.21 -    SDL_NaClMount(
    4.22 +    nacl_io_init_ppapi(PSGetInstanceId(), PSGetInterface);
    4.23 +    
    4.24 +    umount("/");
    4.25 +    mount(
    4.26          "",  /* source */
    4.27          "/",  /* target */
    4.28          "httpfs",  /* filesystemtype */