How to include a data file in a chrome app for a native client module to read

三世轮回 提交于 2019-12-10 10:48:52

问题


If I have a chrome packaged app that also includes a PNaCl/NaCl module, is there a way to include in the packaged app some data files, which the NaCl module will then read in?

I don't need to do any file writing, just to include some data files that the native module needs to make use of.


回答1:


The entire contents of your packaged app are available to both JavaScript and NaCl code via http requests.

If you use the nacl_io library then you can also access all the files using standard POSIX file APIs by first mounting the contents of the package somewhere if your virtual filesystem:

e.g:

// Mount the http root at /mnt/package/
mount("/", "/mnt/package/", "httpfs", 0, "");
FILE* f = fopen("/mnt/package/somefile", "r");


来源:https://stackoverflow.com/questions/23416939/how-to-include-a-data-file-in-a-chrome-app-for-a-native-client-module-to-read

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!