Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
83 lines (75 loc) · 2.56 KB

File metadata and controls

83 lines (75 loc) · 2.56 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* Copyright 2011 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 <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <emscripten.h>
#include <fcntl.h>
#include <sys/stat.h>
int main() {
#ifdef __EMSCRIPTEN_ASMFS__
mkdir("working", 0777);
chdir("working");
close(open("forbidden", O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0000));
close(open("readable", O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0444));
close(open("writeable", O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0222));
close(open("allaccess", O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0777));
#else
EM_ASM(
FS.mkdir('working');
#if NODEFS
FS.mount(NODEFS, { root: '.' }, 'working');
#endif
FS.chdir('working');
FS.writeFile('forbidden', ''); FS.chmod('forbidden', 0000);
FS.writeFile('readable', ''); FS.chmod('readable', 0444);
FS.writeFile('writeable', ''); FS.chmod('writeable', 0222);
FS.writeFile('allaccess', ''); FS.chmod('allaccess', 0777);
);
#endif
// Empty path checks #9136 fix
char* files[] = {"readable", "writeable",
"allaccess", "forbidden", "nonexistent", ""};
for (int i = 0; i < sizeof files / sizeof files[0]; i++) {
printf("F_OK(%s): %d\n", files[i], access(files[i], F_OK));
printf("errno: %d\n", errno);
errno = 0;
printf("R_OK(%s): %d\n", files[i], access(files[i], R_OK));
printf("errno: %d\n", errno);
errno = 0;
printf("X_OK(%s): %d\n", files[i], access(files[i], X_OK));
printf("errno: %d\n", errno);
errno = 0;
printf("W_OK(%s): %d\n", files[i], access(files[i], W_OK));
printf("errno: %d\n", errno);
errno = 0;
printf("\n");
}
EM_ASM({FS.writeFile('filetorename', 'renametest');});
rename("filetorename", "renamedfile");
errno = 0;
printf("F_OK(%s): %d\n", "filetorename", access("filetorename", F_OK));
printf("errno: %d\n", errno);
errno = 0;
printf("F_OK(%s): %d\n", "renamedfile", access("renamedfile", F_OK));
printf("errno: %d\n", errno);
#ifndef __EMSCRIPTEN_ASMFS__
// Restore full permissions on all created files so that python test runner rmtree
// won't have problems on deleting the files. On Windows, calling shutil.rmtree()
// will fail if any of the files are read-only.
EM_ASM(
FS.chmod('forbidden', 0777);
FS.chmod('readable', 0777);
FS.chmod('writeable', 0777);
FS.chmod('allaccess', 0777);
);
#endif
#ifdef REPORT_RESULT
REPORT_RESULT(0);
#endif
return 0;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.