![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /usr/share/emscripten/tests/unistd/ |
Upload File : |
#include <stdio.h> #include <errno.h> #include <unistd.h> #include <emscripten.h> int main() { 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); ); 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"); } // 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); ); return 0; }