2 * Copyright 2008 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
8 * NaCl Service Runtime. Host Directory descriptor / Handle abstraction.
11 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLATFORM_NACL_HOST_DIR_H__
12 #define NATIVE_CLIENT_SRC_TRUSTED_PLATFORM_NACL_HOST_DIR_H__
16 #include "native_client/src/include/portability.h"
18 #include "native_client/src/include/nacl_base.h"
21 # include "native_client/src/shared/platform/linux/nacl_host_dir_types.h"
23 # include "native_client/src/shared/platform/osx/nacl_host_dir_types.h"
25 # include "native_client/src/shared/platform/win/nacl_host_dir_types.h"
32 /* TODO: this is also declared in nacl_host_desc.h */
33 extern int NaClXlateErrno(int errnum);
36 * Constructor for a NaClHostDir object.
38 * path should be a host-OS pathname to a directory. No validation is
41 * Uses raw syscall return convention, so returns 0 for success and
42 * non-zero (usually -NACL_ABI_EINVAL) for failure.
44 * We cannot return the platform descriptor/handle and be consistent
45 * with a largely POSIX-ish interface, since e.g. windows handles may
46 * be negative and might look like negative errno returns.
48 * Underlying function: opendir(Mac) / open(Linux) / FindFirstFile(Windows)
50 extern int NaClHostDirOpen(struct NaClHostDir *d,
54 * Read data from an opened directory into a memory buffer.
56 * Underlying function: readdir(Mac) / getdents(Linux) / FindNextFile(Windows)
58 extern ssize_t NaClHostDirGetdents(struct NaClHostDir *d,
63 * Rewind the NaClHostDir object such that future calls
64 * to NaClHostDirGetdents read from the beginning of the
65 * directory as if the object was newly created.
67 * Underlying functions: rewinddir(Mac) / lseek(Linux) / FindFirstFile(Windows)
69 extern int NaClHostDirRewind(struct NaClHostDir *d);
72 * Dtor for the NaClHostDir object. Close the directory.
74 * Underlying function: closedir(Mac) / close(Linux) / FindClose(Windows)
76 extern int NaClHostDirClose(struct NaClHostDir *d);
80 #endif /* NATIVE_CLIENT_SRC_TRUSTED_PLATFORM_NACL_HOST_DIR_H__ */