forked from emscripten-core/emscripten
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_dir.c
More file actions
49 lines (41 loc) · 1.22 KB
/
test_dir.c
File metadata and controls
49 lines (41 loc) · 1.22 KB
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
/*
* Copyright 2023 The Emscripten Authors. All rights reserved.
* Emscripten is available under two separate licenses, the MIT license and the
* University of Illinois/NCSA Open Source License. Both these licenses can be
* found in the LICENSE file.
*/
#include <assert.h>
#include <emscripten/emscripten.h>
#include <stdio.h>
int main() {
EM_ASM(
// Create multiple directories
var err = FS.mkdir('/dir1');
assert(!err);
err = FS.mkdir('/dir2');
assert(!err);
// Remove the multiple directories
err = FS.rmdir('/dir1');
assert(!err);
err = FS.rmdir('/dir2');
assert(!err);
// Create a directory with a file inside it
var err = FS.mkdir('/test_dir');
assert(!err);
err = FS.writeFile('/test_dir/file.txt', 'Hello World!');
assert(!err);
// Attempt to remove the directory (should fail)
err = FS.rmdir('/test_dir');
assert(err);
// Remove the file and then the directory
err = FS.unlink('/test_dir/file.txt');
assert(!err);
err = FS.rmdir('/test_dir');
assert(!err);
// Attempt to remove a non-existent directory (should fail)
var err = FS.rmdir('/non_existent_dir');
assert(err);
);
puts("success");
return 0;
}