Initialize nacl_io, removes SDL_NaClMount/Umount

It's just easier to use nacl_io's mount/umount directly.
This commit is contained in:
Gabriel Jacobo 2014-06-20 10:59:51 -03:00
parent 199aff7bc2
commit 553cc07e9d
4 changed files with 21 additions and 26 deletions

View File

@ -60,18 +60,17 @@ script will give you instructions on how to do that with Python).
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 @@ connections are involved.
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

View File

@ -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"

View File

@ -179,23 +179,6 @@ extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathT
#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
}

View File

@ -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 @@ nacl_main(int argc, char *argv[])
* 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 */