@@ -22,12 +22,12 @@ using namespace wasmfs;
22
22
23
23
extern " C" {
24
24
25
- __wasi_fd_t wasmfs_create_file (char * pathname, mode_t mode, backend_t backend);
25
+ __wasi_fd_t wasmfs_create_file (const char * pathname, mode_t mode, backend_t backend);
26
26
27
27
// Copy the file specified by the pathname into JS.
28
28
// Return a pointer to the JS buffer in HEAPU8.
29
29
// The buffer will also contain the file length.
30
- void * _wasmfs_read_file (char * path) {
30
+ void * _wasmfs_read_file (const char * path) {
31
31
static_assert (sizeof (off_t ) == 8 , " File offset type must be 64-bit" );
32
32
33
33
struct stat file;
@@ -69,7 +69,7 @@ void* _wasmfs_read_file(char* path) {
69
69
70
70
// Writes to a file, possibly creating it, and returns the number of bytes
71
71
// written successfully. If the file already exists, appends to it.
72
- int _wasmfs_write_file (char * pathname, char * data, size_t data_size) {
72
+ int _wasmfs_write_file (const char * pathname, char * data, size_t data_size) {
73
73
auto parsedParent = path::parseParent (pathname);
74
74
if (parsedParent.getError ()) {
75
75
return 0 ;
@@ -119,33 +119,33 @@ int _wasmfs_write_file(char* pathname, char* data, size_t data_size) {
119
119
return data_size;
120
120
}
121
121
122
- int _wasmfs_mkdir (char * path, mode_t mode) {
122
+ int _wasmfs_mkdir (const char * path, mode_t mode) {
123
123
return __syscall_mkdirat (AT_FDCWD, path, mode);
124
124
}
125
125
126
- int _wasmfs_rmdir (char * path){ return __syscall_unlinkat (AT_FDCWD, path, AT_REMOVEDIR); }
126
+ int _wasmfs_rmdir (const char * path){ return __syscall_unlinkat (AT_FDCWD, path, AT_REMOVEDIR); }
127
127
128
- int _wasmfs_open (char * path, int flags, mode_t mode) {
128
+ int _wasmfs_open (const char * path, int flags, mode_t mode) {
129
129
int err = __syscall_openat (AT_FDCWD, path, flags, mode);
130
130
if (err == -1 ) {
131
131
return -errno;
132
132
}
133
133
return err;
134
134
}
135
135
136
- int _wasmfs_mknod (char * path, mode_t mode, dev_t dev) {
136
+ int _wasmfs_mknod (const char * path, mode_t mode, dev_t dev) {
137
137
int err = __syscall_mknodat (AT_FDCWD, path, mode, dev);
138
138
if (err == -1 ) {
139
139
return errno;
140
140
}
141
141
return err;
142
142
}
143
143
144
- int _wasmfs_unlink (char * path) {
144
+ int _wasmfs_unlink (const char * path) {
145
145
return __syscall_unlinkat (AT_FDCWD, path, 0 );
146
146
}
147
147
148
- int _wasmfs_chdir (char * path) { return __syscall_chdir (path); }
148
+ int _wasmfs_chdir (const char * path) { return __syscall_chdir (path); }
149
149
150
150
int _wasmfs_symlink (char * old_path, char * new_path) {
151
151
return __syscall_symlink (old_path, new_path);
@@ -177,19 +177,19 @@ int _wasmfs_pwrite(int fd, void *buf, size_t count, off_t offset) {
177
177
return numBytes;
178
178
}
179
179
180
- int _wasmfs_chmod (char * path, mode_t mode) {
180
+ int _wasmfs_chmod (const char * path, mode_t mode) {
181
181
return __syscall_chmod (path, mode);
182
182
}
183
183
184
184
int _wasmfs_fchmod (int fd, mode_t mode) {
185
185
return __syscall_fchmod (fd, mode);
186
186
}
187
187
188
- int _wasmfs_lchmod (char * path, mode_t mode) {
188
+ int _wasmfs_lchmod (const char * path, mode_t mode) {
189
189
return __syscall_fchmodat (AT_FDCWD, path, mode, AT_SYMLINK_NOFOLLOW);
190
190
}
191
191
192
- int _wasmfs_rename (char * oldpath, char * newpath) {
192
+ int _wasmfs_rename (const char * oldpath, const char * newpath) {
193
193
int err = __syscall_renameat (AT_FDCWD, oldpath, AT_FDCWD, newpath);
194
194
if (err == -1 ) {
195
195
return errno;
@@ -227,15 +227,15 @@ int _wasmfs_close(int fd) {
227
227
return __wasi_fd_close (fd);
228
228
}
229
229
230
- int _wasmfs_stat (char * path, struct stat * statBuf) {
230
+ int _wasmfs_stat (const char * path, struct stat * statBuf) {
231
231
int err = __syscall_stat64 (path, statBuf);
232
232
if (err == -1 ) {
233
233
return errno;
234
234
}
235
235
return err;
236
236
}
237
237
238
- int _wasmfs_lstat (char * path, struct stat * statBuf) {
238
+ int _wasmfs_lstat (const char * path, struct stat * statBuf) {
239
239
int err = __syscall_lstat64 (path, statBuf);
240
240
if (err == -1 ) {
241
241
return errno;
@@ -247,7 +247,7 @@ int _wasmfs_lstat(char* path, struct stat* statBuf) {
247
247
// ENOENT - if nothing exists there
248
248
// EISDIR - if it is a directory
249
249
// EEXIST - if it is a normal file
250
- int _wasmfs_identify (char * path) {
250
+ int _wasmfs_identify (const char * path) {
251
251
struct stat file;
252
252
int err = 0 ;
253
253
err = stat (path, &file);
@@ -266,7 +266,7 @@ struct wasmfs_readdir_state {
266
266
struct dirent ** entries;
267
267
};
268
268
269
- struct wasmfs_readdir_state * _wasmfs_readdir_start (char * path) {
269
+ struct wasmfs_readdir_state * _wasmfs_readdir_start (const char * path) {
270
270
struct dirent ** entries;
271
271
int nentries = scandir (path, &entries, NULL , alphasort);
272
272
if (nentries == -1 ) {
0 commit comments