imcplugin demo: Extend to support stat() call
[nativeclient.git] / service_runtime / nacl_host_dir.h
blobde0f62cfeab980fa507dfc037ff5f90122484ab7
1 /*
2 * Copyright 2008, Google Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * NaCl Service Runtime. Host Directory descriptor / Handle abstraction.
36 #ifndef NATIVE_CLIENT_SERVICE_RUNTIME_NACL_HOST_DIR_H__
37 #define NATIVE_CLIENT_SERVICE_RUNTIME_NACL_HOST_DIR_H__
39 #include <errno.h>
41 #include "native_client/include/portability.h"
43 #include "native_client/include/nacl_base.h"
45 #if NACL_LINUX
46 # include "native_client/service_runtime/linux/nacl_host_dir_types.h"
47 #elif NACL_OSX
48 # include "native_client/service_runtime/osx/nacl_host_dir_types.h"
49 #elif NACL_WINDOWS
50 # include "native_client/service_runtime/win/nacl_host_dir_types.h"
51 #endif
53 EXTERN_C_BEGIN
55 struct nacl_abi_stat;
57 extern int NaClXlateErrno(int errnum);
60 * Constructor for a NaClHostDir object.
62 * path should be a host-OS pathname to a directory. No validation is
63 * done.
65 * Uses raw syscall return convention, so returns 0 for success and
66 * non-zero (usually -NACL_ABI_EINVAL) for failure.
68 * We cannot return the platform descriptor/handle and be consistent
69 * with a largely POSIX-ish interface, since e.g. windows handles may
70 * be negative and might look like negative errno returns.
72 * Underlying host-OS functions: opendir(Mac) / open(Linux) / FindFirstFile
74 extern int NaClHostDirOpen(struct NaClHostDir *d,
75 char *path);
78 * Read data from an opened directory into a memory buffer.
80 * Underlying host-OS functions: readdir(Mac) / getdents(Linux) / FindNextFile
82 extern ssize_t NaClHostDirGetdents(struct NaClHostDir *d,
83 void *buf,
84 size_t len);
87 * Dtor for the NaClHostDir object. Close the directory.
89 * Underlying host-OS functions: closedir(Mac) / close(Linux) / FindClose
91 extern int NaClHostDirClose(struct NaClHostDir *d);
93 EXTERN_C_END
95 #endif /* NATIVE_CLIENT_SERVICE_RUNTIME_NACL_HOST_DIR_H__ */