forked from WebAssembly/wasi-libc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibc-find-relpath.h
51 lines (46 loc) · 2 KB
/
libc-find-relpath.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef __wasi_libc_find_relpath_h
#define __wasi_libc_find_relpath_h
#ifdef __cplusplus
extern "C" {
#endif
/**
* Look up the given `path`, relative to the cwd, in the preopened directory
* map. If a suitable entry is found, then the file descriptor for that entry
* is returned. Additionally the absolute path of the directory's file
* descriptor is returned in `abs_prefix` and the relative portion that needs
* to be opened is stored in `*relative_path`.
*
* The `relative_path` argument must be a pointer to a buffer valid for
* `relative_path_len` bytes, and this may be used as storage for the relative
* portion of the path being returned through `*relative_path`.
*
* Returns -1 on failure. Errno is set to either:
*
* * ENOMEM - failed to allocate memory for internal routines.
* * ENOENT - the `path` could not be found relative to any preopened dir.
* * ERANGE - the `relative_path` buffer is too small to hold the relative path.
*/
int __wasilibc_find_relpath(const char *path,
const char **__restrict__ abs_prefix,
char **relative_path,
size_t relative_path_len);
/**
* Look up the given `path`, which is interpreted as absolute, in the preopened
* directory map. If a suitable entry is found, then the file descriptor for
* that entry is returned. Additionally the relative portion of the path to
* where the fd is opened is returned through `relative_path`, the absolute
* prefix which was matched is stored to `abs_prefix`, and `relative_path` may
* be an interior pointer to the `abspath` string.
*
* Returns -1 on failure. Errno is set to either:
*
* * ENOMEM - failed to allocate memory for internal routines.
* * ENOENT - the `path` could not be found relative to any preopened dir.
*/
int __wasilibc_find_abspath(const char *abspath,
const char **__restrict__ abs_prefix,
const char **__restrict__ relative_path);
#ifdef __cplusplus
}
#endif
#endif