c++clang++google-nativeclient

How to create and open a file system through the Chrome Pepper C API?


The Pepper C API for Chrome browsers is defined here:

https://developer.chrome.com/native-client/c-api

I am trying to create and open a file system through the C API for use in a Chrome app that uses PNaCl technology.

Here is a shortened version of the variables:

static PP_Instance pp_instance;
static PPB_Instance * ppb_instance;

Here is a reference to the Pepper FileSystem:

https://developer.chrome.com/native-client/pepper_stable/c/struct_p_p_b___file_system__1__0

I tried the following code samples to initialize a file system but all of them give compiler errors.

PPB_FileSystem pepper_file_system;

Compiling this code trough clang++ ...

pepper_file_system = PPB_FileSystem::Create (pp_instance, PP_FILESYSTEMTYPE_LOCALPERSISTENT);

gives this output:

invalid use of non-static data member 'Create'
pepper_file_system = PPB_FileSystem::Create (pp_instance, PP_FILESYSTE...

Second try, compiling this code...

pepper_file_system = PPB_FileSystem->Create (pp_instance, PP_FILESYSTEMTYPE_LOCALPERSISTENT);

gives this output:

error: unexpected type name 'PPB_FileSystem': expected expression
pepper_file_system = PPB_FileSystem->Create (pp_instance, PP_FILESYSTE...

Third try, compiling this code...

pepper_file_system = ppb_instance->Create (pp_instance, PP_FILESYSTEMTYPE_LOCALPERSISTENT);

gives this output:

error: no member named 'Create' in 'PPB_Instance_1_0'
pepper_file_system = ppb_instance->Create (pp_instance, PP_FILESYSTEMT...

I realize that this must be a very beginner's question, obviously the solution must be very simple, just I've been looking at this for several hours, and googling on sample code for creating a file system through the Pepper C API, and not finding it (there is sample code for the C++ API). Thanks for any help that solves this puzzle... :)


Solution

  • Something like:

    PPB_FileSystem * ppb_file_system = new PPB_FileSystem;
    PP_Resource pp_file_system = ppb_file_system->Create (pp_instance, PP_FILESYSTEMTYPE_LOCALPERSISTENT);
    

    should work