Skip to content

Commit

Permalink
Initialize nacl_io, removes SDL_NaClMount/Umount
Browse files Browse the repository at this point in the history
It's just easier to use nacl_io's mount/umount directly.
  • Loading branch information
gabomdq committed Jun 20, 2014
1 parent 199aff7 commit 553cc07
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 26 deletions.
20 changes: 15 additions & 5 deletions README-nacl.txt
Expand Up @@ -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 /

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion build-scripts/naclbuild.sh
@@ -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"
Expand Down
17 changes: 0 additions & 17 deletions include/SDL_system.h
Expand Up @@ -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
}
Expand Down
8 changes: 5 additions & 3 deletions src/main/nacl/SDL_nacl_main.c
Expand Up @@ -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);

Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit 553cc07

Please sign in to comment.