Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 .. _nacl_io: | 1 .. _nacl_io: |
| 2 | 2 |
| 3 ################### | 3 ################### |
| 4 The nacl_io Library | 4 The nacl_io Library |
| 5 ################### | 5 ################### |
| 6 | 6 |
| 7 .. contents:: | 7 .. contents:: |
| 8 :local: | 8 :local: |
| 9 :backlinks: none | 9 :backlinks: none |
| 10 :depth: 2 | 10 :depth: 2 |
| 11 | 11 |
| 12 Introduction | 12 Introduction |
| 13 ============ | 13 ============ |
| 14 | 14 |
| 15 ``nacl_io`` is a utility library that provides implementations of standard | 15 ``nacl_io`` is a utility library that provides implementations of standard |
| 16 C APIs such as POSIX I/O (``stdio.h``) and BSD sockets (``sys/socket.h``). | 16 C APIs such as POSIX I/O (``stdio.h``) and BSD sockets (``sys/socket.h``). |
| 17 Its primary function is to allow code that uses these standard APIs to be | 17 Its primary function is to allow code that uses these standard APIs to be |
| 18 compiled and used in a Native Client module. The library is included as part | 18 compiled and used in a Native Client module. The library is included as part |
| 19 of Native Client SDK and is implemented in on top of Pepper API. | 19 of Native Client SDK and is implemented in on top of Pepper API. |
| 20 | 20 |
| 21 Since Native Client modules cannot access the host machine's file system | 21 Since Native Client modules cannot access the host machine's file system |
| 22 directly, nacl_io provides several alternative filesystem types which | 22 directly, nacl_io provides several alternative filesystem types which can be |
| 23 can be used by the application. For example, the Chrome browser supports the | 23 used by the application. For example, the Chrome browser supports the `HTML5 |
| 24 `HTML5 File System API | 24 File System API <http://www.html5rocks.com/en/tutorials/file/filesystem/>`_ |
| 25 <http://www.html5rocks.com/en/tutorials/file/filesystem/>`_ which provides | 25 which provides access to a protected area of the local file system. This |
| 26 access to a protected area of the local file system. This filesystem can | 26 filesystem can be accessed by an HTML page using JavaScript commands, and also |
| 27 be accessed by an HTML page using JavaScript commands, and also by a Native | 27 by a Native Client module using the Pepper :doc:`File IO API <file-io>`. |
| 28 Client module using the Pepper :doc:`File IO API <file-io>`. With nacl_io | 28 |
| 29 a Native Client application can mount an HTML5 filesystem and access it via | 29 With nacl_io a Native Client application can mount an HTML5 filesystem and |
| 30 standard POSIX I/O function such as ``fopen``, ``fseek``, ``fread``, | 30 access it via standard POSIX I/O function such as ``fopen``, ``fseek``, |
| 31 ``fwrite``, and ``fclose``, or their low level UNIX counterparts ``open``, | 31 ``fread``, ``fwrite``, and ``fclose``, or their low level UNIX counterparts |
| 32 ``lseek``, ``read``, ``write`` and ``close``. | 32 ``open``, ``lseek``, ``read``, ``write`` and ``close``. Unlike most input/output |
| 33 for nacl_io, logging writes directly to the ``stderr`` stream of the NaCl | |
|
Sam Clegg
2014/10/01 21:52:14
, internal logging and error reporting writes dire
jpmedley
2014/10/07 17:01:42
Done.
| |
| 34 process. It deliberately bypasses the standard library functions implemented in | |
| 35 nacl_io to avoid circular calls to itself. | |
|
Sam Clegg
2014/10/01 21:52:14
Perhaps put this in sub-sub-section called "Loggin
jpmedley
2014/10/07 17:01:42
Done.
| |
| 33 | 36 |
| 34 As well as the HTML5 file system, nacl_io provides several other file system | 37 As well as the HTML5 file system, nacl_io provides several other file system |
| 35 types which are described in the table below: | 38 types which are described in the table below: |
| 36 | 39 |
| 37 =========== ================================================================== | 40 =========== ================================================================== |
| 38 File System Description | 41 File System Description |
| 39 =========== ================================================================== | 42 =========== ================================================================== |
| 40 memfs An in-memory file system | 43 memfs An in-memory file system |
| 41 html5fs An HTML5 local file system, which can be persistent or temporary | 44 html5fs An HTML5 local file system, which can be persistent or temporary |
| 42 http Maps files on a remote webserver into the local filesystem. | 45 http Maps files on a remote webserver into the local filesystem. |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 return 2; | 208 return 2; |
| 206 } | 209 } |
| 207 | 210 |
| 208 bytes_written = fwrite(data, 1, data_len, file); | 211 bytes_written = fwrite(data, 1, data_len, file); |
| 209 | 212 |
| 210 *output = PrintfToNewString("fwrite\1%s\1%d", file_index_string, | 213 *output = PrintfToNewString("fwrite\1%s\1%d", file_index_string, |
| 211 bytes_written); | 214 bytes_written); |
| 212 return 0; | 215 return 0; |
| 213 } | 216 } |
| 214 | 217 |
| 215 Reference information | 218 Reference Information |
| 216 ===================== | 219 ===================== |
| 217 | 220 |
| 218 The example discussed here is included in the SDK in the directory | 221 The example discussed here is included in the SDK in the directory |
| 219 ``examples/demo/nacl_io_demo``. | 222 ``examples/demo/nacl_io_demo``. |
| 220 | 223 |
| 221 The nacl_io library is included in the SDK toolchain and is not a part of the | 224 The nacl_io library is included in the SDK toolchain and is not a part of the |
| 222 Pepper API. For reference information related to the nacl_io interface see | 225 Pepper API. For reference information related to the nacl_io interface see |
| 223 its header file in the SDK directory, located at | 226 its header file in the SDK directory, located at |
| 224 ``include/nacl_io/nacl_io.h``. | 227 ``include/nacl_io/nacl_io.h``. |
| 225 | 228 |
| 226 For more about the HTML5 file system read the `specification | 229 For more about the HTML5 file system read the `specification |
| 227 <http://dev.w3.org/2009/dap/file-system/pub/FileSystem/>`_. | 230 <http://dev.w3.org/2009/dap/file-system/pub/FileSystem/>`_. |
| OLD | NEW |