os_js.odin 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. //+build js
  2. package os
  3. import "base:runtime"
  4. is_path_separator :: proc(c: byte) -> bool {
  5. return c == '/' || c == '\\'
  6. }
  7. open :: proc(path: string, mode: int = O_RDONLY, perm: int = 0) -> (Handle, Errno) {
  8. unimplemented("core:os procedure not supported on JS target")
  9. }
  10. close :: proc(fd: Handle) -> Errno {
  11. unimplemented("core:os procedure not supported on JS target")
  12. }
  13. flush :: proc(fd: Handle) -> (err: Errno) {
  14. unimplemented("core:os procedure not supported on JS target")
  15. }
  16. write :: proc(fd: Handle, data: []byte) -> (int, Errno) {
  17. unimplemented("core:os procedure not supported on JS target")
  18. }
  19. @(private="file")
  20. read_console :: proc(handle: Handle, b: []byte) -> (n: int, err: Errno) {
  21. unimplemented("core:os procedure not supported on JS target")
  22. }
  23. read :: proc(fd: Handle, data: []byte) -> (int, Errno) {
  24. unimplemented("core:os procedure not supported on JS target")
  25. }
  26. seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Errno) {
  27. unimplemented("core:os procedure not supported on JS target")
  28. }
  29. file_size :: proc(fd: Handle) -> (i64, Errno) {
  30. unimplemented("core:os procedure not supported on JS target")
  31. }
  32. @(private)
  33. MAX_RW :: 1<<30
  34. @(private)
  35. pread :: proc(fd: Handle, data: []byte, offset: i64) -> (int, Errno) {
  36. unimplemented("core:os procedure not supported on JS target")
  37. }
  38. @(private)
  39. pwrite :: proc(fd: Handle, data: []byte, offset: i64) -> (int, Errno) {
  40. unimplemented("core:os procedure not supported on JS target")
  41. }
  42. read_at :: proc(fd: Handle, data: []byte, offset: i64) -> (n: int, err: Errno) {
  43. unimplemented("core:os procedure not supported on JS target")
  44. }
  45. write_at :: proc(fd: Handle, data: []byte, offset: i64) -> (n: int, err: Errno) {
  46. unimplemented("core:os procedure not supported on JS target")
  47. }
  48. stdout: Handle = 1
  49. stderr: Handle = 2
  50. get_std_handle :: proc "contextless" (h: uint) -> Handle {
  51. context = runtime.default_context()
  52. unimplemented("core:os procedure not supported on JS target")
  53. }
  54. exists :: proc(path: string) -> bool {
  55. unimplemented("core:os procedure not supported on JS target")
  56. }
  57. is_file :: proc(path: string) -> bool {
  58. unimplemented("core:os procedure not supported on JS target")
  59. }
  60. is_dir :: proc(path: string) -> bool {
  61. unimplemented("core:os procedure not supported on JS target")
  62. }
  63. // NOTE(tetra): GetCurrentDirectory is not thread safe with SetCurrentDirectory and GetFullPathName
  64. //@private cwd_lock := win32.SRWLOCK{} // zero is initialized
  65. get_current_directory :: proc(allocator := context.allocator) -> string {
  66. unimplemented("core:os procedure not supported on JS target")
  67. }
  68. set_current_directory :: proc(path: string) -> (err: Errno) {
  69. unimplemented("core:os procedure not supported on JS target")
  70. }
  71. change_directory :: proc(path: string) -> (err: Errno) {
  72. unimplemented("core:os procedure not supported on JS target")
  73. }
  74. make_directory :: proc(path: string, mode: u32 = 0) -> (err: Errno) {
  75. unimplemented("core:os procedure not supported on JS target")
  76. }
  77. remove_directory :: proc(path: string) -> (err: Errno) {
  78. unimplemented("core:os procedure not supported on JS target")
  79. }
  80. @(private)
  81. is_abs :: proc(path: string) -> bool {
  82. unimplemented("core:os procedure not supported on JS target")
  83. }
  84. @(private)
  85. fix_long_path :: proc(path: string) -> string {
  86. unimplemented("core:os procedure not supported on JS target")
  87. }
  88. link :: proc(old_name, new_name: string) -> (err: Errno) {
  89. unimplemented("core:os procedure not supported on JS target")
  90. }
  91. unlink :: proc(path: string) -> (err: Errno) {
  92. unimplemented("core:os procedure not supported on JS target")
  93. }
  94. rename :: proc(old_path, new_path: string) -> (err: Errno) {
  95. unimplemented("core:os procedure not supported on JS target")
  96. }
  97. ftruncate :: proc(fd: Handle, length: i64) -> (err: Errno) {
  98. unimplemented("core:os procedure not supported on JS target")
  99. }
  100. truncate :: proc(path: string, length: i64) -> (err: Errno) {
  101. unimplemented("core:os procedure not supported on JS target")
  102. }
  103. remove :: proc(name: string) -> Errno {
  104. unimplemented("core:os procedure not supported on JS target")
  105. }
  106. pipe :: proc() -> (r, w: Handle, err: Errno) {
  107. unimplemented("core:os procedure not supported on JS target")
  108. }
  109. read_dir :: proc(fd: Handle, n: int, allocator := context.allocator) -> (fi: []File_Info, err: Errno) {
  110. unimplemented("core:os procedure not supported on JS target")
  111. }
  112. Handle :: distinct uintptr
  113. File_Time :: distinct u64
  114. Errno :: distinct int
  115. INVALID_HANDLE :: ~Handle(0)
  116. O_RDONLY :: 0x00000
  117. O_WRONLY :: 0x00001
  118. O_RDWR :: 0x00002
  119. O_CREATE :: 0x00040
  120. O_EXCL :: 0x00080
  121. O_NOCTTY :: 0x00100
  122. O_TRUNC :: 0x00200
  123. O_NONBLOCK :: 0x00800
  124. O_APPEND :: 0x00400
  125. O_SYNC :: 0x01000
  126. O_ASYNC :: 0x02000
  127. O_CLOEXEC :: 0x80000
  128. ERROR_NONE: Errno : 0
  129. ERROR_FILE_NOT_FOUND: Errno : 2
  130. ERROR_PATH_NOT_FOUND: Errno : 3
  131. ERROR_ACCESS_DENIED: Errno : 5
  132. ERROR_INVALID_HANDLE: Errno : 6
  133. ERROR_NOT_ENOUGH_MEMORY: Errno : 8
  134. ERROR_NO_MORE_FILES: Errno : 18
  135. ERROR_HANDLE_EOF: Errno : 38
  136. ERROR_NETNAME_DELETED: Errno : 64
  137. ERROR_FILE_EXISTS: Errno : 80
  138. ERROR_INVALID_PARAMETER: Errno : 87
  139. ERROR_BROKEN_PIPE: Errno : 109
  140. ERROR_BUFFER_OVERFLOW: Errno : 111
  141. ERROR_INSUFFICIENT_BUFFER: Errno : 122
  142. ERROR_MOD_NOT_FOUND: Errno : 126
  143. ERROR_PROC_NOT_FOUND: Errno : 127
  144. ERROR_DIR_NOT_EMPTY: Errno : 145
  145. ERROR_ALREADY_EXISTS: Errno : 183
  146. ERROR_ENVVAR_NOT_FOUND: Errno : 203
  147. ERROR_MORE_DATA: Errno : 234
  148. ERROR_OPERATION_ABORTED: Errno : 995
  149. ERROR_IO_PENDING: Errno : 997
  150. ERROR_NOT_FOUND: Errno : 1168
  151. ERROR_PRIVILEGE_NOT_HELD: Errno : 1314
  152. WSAEACCES: Errno : 10013
  153. WSAECONNRESET: Errno : 10054
  154. // Windows reserves errors >= 1<<29 for application use
  155. ERROR_FILE_IS_PIPE: Errno : 1<<29 + 0
  156. ERROR_FILE_IS_NOT_DIR: Errno : 1<<29 + 1
  157. ERROR_NEGATIVE_OFFSET: Errno : 1<<29 + 2
  158. // "Argv" arguments converted to Odin strings
  159. args := _alloc_command_line_arguments()
  160. last_write_time :: proc(fd: Handle) -> (File_Time, Errno) {
  161. unimplemented("core:os procedure not supported on JS target")
  162. }
  163. last_write_time_by_name :: proc(name: string) -> (File_Time, Errno) {
  164. unimplemented("core:os procedure not supported on JS target")
  165. }
  166. get_page_size :: proc() -> int {
  167. unimplemented("core:os procedure not supported on JS target")
  168. }
  169. @(private)
  170. _processor_core_count :: proc() -> int {
  171. unimplemented("core:os procedure not supported on JS target")
  172. }
  173. exit :: proc "contextless" (code: int) -> ! {
  174. context = runtime.default_context()
  175. unimplemented("core:os procedure not supported on JS target")
  176. }
  177. current_thread_id :: proc "contextless" () -> int {
  178. context = runtime.default_context()
  179. unimplemented("core:os procedure not supported on JS target")
  180. }
  181. _alloc_command_line_arguments :: proc() -> []string {
  182. return nil
  183. }