Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/system/lib/wasmfs/backends/node_backend.h
6175 views
1
// Copyright 2022 The Emscripten Authors. All rights reserved.
2
// Emscripten is available under two separate licenses, the MIT license and the
3
// University of Illinois/NCSA Open Source License. Both these licenses can be
4
// found in the LICENSE file.
5
6
#include <sys/stat.h> // for mode_t
7
8
extern "C" {
9
10
// These helper functions are defined in library_wasmfs_node.js.
11
12
// Fill `entries` and return 0 or an error code.
13
int _wasmfs_node_readdir(const char* path, void* entries
14
/* std::vector<Directory::Entry>*/);
15
// Write `mode` and return 0 or an error code.
16
int _wasmfs_node_get_mode(const char* path, mode_t* mode);
17
18
// Write `size` and return 0 or an error code.
19
int _wasmfs_node_stat_size(const char* path, uint32_t* size);
20
int _wasmfs_node_fstat_size(int fd, uint32_t* size);
21
22
// Create a new file system entry and return 0 or an error code.
23
int _wasmfs_node_insert_file(const char* path, mode_t mode);
24
int _wasmfs_node_insert_directory(const char* path, mode_t mode);
25
26
// Unlink the given file and return 0 or an error code.
27
int _wasmfs_node_unlink(const char* path);
28
int _wasmfs_node_rmdir(const char* path);
29
30
int _wasmfs_node_truncate(const char* path, off_t len);
31
int _wasmfs_node_ftruncate(int fd, off_t len);
32
33
int _wasmfs_node_rename(const char* oldpath, const char* newpath);
34
35
int _wasmfs_node_symlink(const char *target, const char *linkpath);
36
37
int _wasmfs_node_readlink(const char *path, const char *buf, int bufsize);
38
39
// Open the file and return the underlying file descriptor.
40
[[nodiscard]] int _wasmfs_node_open(const char* path, const char* mode);
41
42
// Close the underlying file descriptor.
43
[[nodiscard]] int _wasmfs_node_close(int fd);
44
45
// Read up to `size` bytes into `buf` from position `pos` in the file, writing
46
// the number of bytes read to `nread`. Return 0 on success or an error code.
47
int _wasmfs_node_read(
48
int fd, void* buf, uint32_t len, uint32_t pos, uint32_t* nread);
49
50
// Write up to `size` bytes from `buf` at position `pos` in the file, writing
51
// the number of bytes written to `nread`. Return 0 on success or an error code.
52
int _wasmfs_node_write(
53
int fd, const void* buf, uint32_t len, uint32_t pos, uint32_t* nwritten);
54
55
} // extern "C"
56
57