Initialize nacl_io, removes SDL_NaClMount/Umount
authorGabriel Jacobo <gabomdq@gmail.com>
Fri, 20 Jun 2014 10:59:51 -0300
changeset 8877 0d691f3734ac
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
--- a/README-nacl.txt	Thu Jun 19 00:40:09 2014 -0400
+++ b/README-nacl.txt	Fri Jun 20 10:59:51 2014 -0300
@@ -60,18 +60,17 @@
 RWops and nacl_io
 ================================================================================
 
-SDL_RWops work transparently with nacl_io. Two functions are provided to control
-mount points:
+SDL_RWops work transparently with nacl_io. Two functions control the mount points:
     
-    int SDL_NaClMount(const char* source, const char* target, 
+    int mount(const char* source, const char* target, 
                       const char* filesystemtype, 
                       unsigned long mountflags, const void *data);
-    int SDL_NaClUmount(const char *target);
+    int umount(const char *target);
     
     For convenience, SDL will by default mount an httpfs tree at / before calling 
 the app's main function. Such setting can be overridden by calling:
     
-    SDL_NaClUmount("/");
+    umount("/");
 
 And then mounting a different filesystem at /
 
@@ -85,6 +84,17 @@
 For more information on how nacl_io and mount points work, see:
     
     https://developer.chrome.com/native-client/devguide/coding/nacl_io
+    https://src.chromium.org/chrome/trunk/src/native_client_sdk/src/libraries/nacl_io/nacl_io.h
+
+To be able to save into the directory "/save/" (like backup of game) :
+
+    mount("", "/save", "html5fs", 0, "type=PERSISTENT");
+
+And add to manifest.json :
+
+  "permissions": [
+     "unlimitedStorage"
+  ]
 
 ================================================================================
 TODO - Known Issues
--- a/build-scripts/naclbuild.sh	Thu Jun 19 00:40:09 2014 -0400
+++ b/build-scripts/naclbuild.sh	Fri Jun 20 10:59:51 2014 -0300
@@ -1,6 +1,6 @@
 #!/bin/bash
 if [ -z "$1" ] && [ -z "$NACL_SDK_ROOT" ]; then
-    echo "Usage: ./naclbuild ~/nacl/pepper_33"
+    echo "Usage: ./naclbuild ~/nacl/pepper_35"
     echo "This will build SDL for Native Client, and testgles2.c as a demo"
     echo "You can set env vars CC, AR, LD and RANLIB to override the default PNaCl toolchain used"
     echo "You can set env var SOURCES to select a different source file than testgles2.c"
--- a/include/SDL_system.h	Thu Jun 19 00:40:09 2014 -0400
+++ b/include/SDL_system.h	Fri Jun 20 10:59:51 2014 -0300
@@ -179,23 +179,6 @@
 
 #endif /* __WINRT__ */
 
-#ifdef __NACL__
-
-/**
- *  \name Mount/umount functions
- *
- *  Required for RWOps on Native Client
- */
-/* @{ */
-extern DECLSPEC int SDLCALL SDL_NaClMount(const char* source, const char* target, 
-                                        const char* filesystemtype, 
-                                        unsigned long mountflags, const void *data);
-
-extern DECLSPEC int SDLCALL SDL_NaClUmount(const char *target);
-
-#endif /* __NACL__ */
-
-
 /* Ends C function definitions when using C++ */
 #ifdef __cplusplus
 }
--- a/src/main/nacl/SDL_nacl_main.c	Thu Jun 19 00:40:09 2014 -0400
+++ b/src/main/nacl/SDL_nacl_main.c	Fri Jun 20 10:59:51 2014 -0300
@@ -24,11 +24,11 @@
 
 /* Include the SDL main definition header */
 #include "SDL_main.h"
-#include "SDL_system.h"
 
 #include "ppapi_simple/ps_main.h"
 #include "ppapi_simple/ps_event.h"
 #include "ppapi_simple/ps_interface.h"
+#include "nacl_io/nacl_io.h"
 
 extern void NACL_SetScreenResolution(int width, int height, Uint32 format);
 
@@ -69,8 +69,10 @@
      * apps can override this by unmounting / 
      * and remounting with the desired configuration
      */
-    SDL_NaClUmount("/");
-    SDL_NaClMount(
+    nacl_io_init_ppapi(PSGetInstanceId(), PSGetInterface);
+    
+    umount("/");
+    mount(
         "",  /* source */
         "/",  /* target */
         "httpfs",  /* filesystemtype */