File tree Expand file tree Collapse file tree 6 files changed +77
-1
lines changed Expand file tree Collapse file tree 6 files changed +77
-1
lines changed Original file line number Diff line number Diff line change
1
+ #include <fcntl.h>
2
+ #include <string.h>
3
+ #include <stdbool.h>
4
+ #include <assert.h>
5
+ #include <stdio.h>
6
+ #include <stdlib.h>
7
+ #include <stdint.h>
8
+ #include <dirent.h>
9
+ #include <errno.h>
10
+ #include <limits.h>
11
+ #include <sys/stat.h>
12
+ #include <unistd.h>
13
+
14
+ #define perror_and_exit (message ) \
15
+ do { \
16
+ perror(message); \
17
+ return EXIT_FAILURE; \
18
+ } while (0)
19
+
20
+ #define OFFSET 10726
21
+ #define LENGTH 143
22
+
23
+ int main (int argc , char * argv []) {
24
+ if (argc != 2 ) {
25
+ fprintf (stderr , "usage: %s <dir>\n" , argv [0 ]);
26
+ return EXIT_FAILURE ;
27
+ }
28
+ DIR * dir = opendir (argv [1 ]);
29
+ if (dir == NULL ) {
30
+ perror_and_exit ("opendir" );
31
+ }
32
+
33
+ int count = 0 ;
34
+ int zeros = 0 ;
35
+ errno = 0 ;
36
+ for (;; count += 1 ) {
37
+ struct dirent * ent = readdir (dir );
38
+ if (ent == NULL ) {
39
+ if (errno == 0 ) {
40
+ break ;
41
+ }
42
+ perror_and_exit ("readdir" );
43
+ }
44
+
45
+ if (strcmp (ent -> d_name , "file.md" ) == 0 ) {
46
+ assert (ent -> d_type == DT_REG );
47
+ } else if (strcmp (ent -> d_name , "dir" ) == 0 ) {
48
+ assert (ent -> d_type == DT_DIR );
49
+ } else if (strcmp (ent -> d_name , "file-symlink" ) == 0 ) {
50
+ assert (ent -> d_type == DT_LNK );
51
+ } else if (strcmp (ent -> d_name , "dir-symlink" ) == 0 ) {
52
+ assert (ent -> d_type == DT_LNK );
53
+ } else if (strcmp (ent -> d_name , "." ) == 0 ) {
54
+ assert (ent -> d_type == DT_DIR );
55
+ } else if (strcmp (ent -> d_name , ".." ) == 0 ) {
56
+ assert (ent -> d_type == DT_DIR );
57
+ } else {
58
+ assert (false);
59
+ }
60
+ if (ent -> d_ino == 0 ) {
61
+ zeros += 1 ;
62
+ }
63
+ }
64
+
65
+ assert (count == 6 );
66
+ assert (zeros <= 1 );
67
+
68
+ if (closedir (dir ) != 0 )
69
+ perror_and_exit ("closedir" );
70
+
71
+ return EXIT_SUCCESS ;
72
+ }
Original file line number Diff line number Diff line change
1
+ dir
Original file line number Diff line number Diff line change
1
+ This is a file in a directory.
Original file line number Diff line number Diff line change
1
+ file.md
Original file line number Diff line number Diff line change
1
+ # This is a top-level file
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ set -ueo pipefail
10
10
# location. Alternatively, exporting $CC and $CXX allow more flexibility. e.g:
11
11
#
12
12
# export CXX="<wasi-sdk>/bin/clang++ --sysroot <wasi-sdk>/share/wasi-sysroot"
13
- # export CCC ="<wasi-sdk>/bin/clang --sysroot <wasi-sdk>/share/wasi-sysroot"
13
+ # export CC ="<wasi-sdk>/bin/clang --sysroot <wasi-sdk>/share/wasi-sysroot"
14
14
#
15
15
16
16
# Determine the wasm runtime to use, if one is provided.
You can’t perform that action at this time.
0 commit comments