如何在chrome应用程序中包含数据文件以供本机客户端模块读取 [英] How to include a data file in a chrome app for a native client module to read

查看:56
本文介绍了如何在chrome应用程序中包含数据文件以供本机客户端模块读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的Chrome打包应用程序还包含PNaCl/NaCl模块,是否可以在打包的应用程序中包含一些数据文件,然后NaCl模块会读取这些文件?

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.

推荐答案

打包的应用程序的全部内容都可以通过http请求提供给JavaScript和NaCl代码.

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

如果使用nacl_io库,则还可以使用标准POSIX文件API访问所有文件,方法是先将软件包的内容挂载到虚拟文件系统中的某个位置:

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:

例如:

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

这篇关于如何在chrome应用程序中包含数据文件以供本机客户端模块读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆