v / vlib / os
Raw file | 163 loc (148 sloc) | 5.35 KB | Latest commit hash ca484430e
1module os
2
3const max_path_buffer_size = 2 * max_path_len
4
5// Ref - winnt.h
6const (
7 success = 0x0000 // ERROR_SUCCESS
8 error_insufficient_buffer = 0x0082
9)
10
11const (
12 handle_generic_read = u32(0x80000000)
13 handle_open_existing = 0x00000003
14)
15
16const (
17 file_share_read = 0x01
18 file_share_write = 0x02
19 file_share_delete = 0x04
20)
21
22const (
23 file_notify_change_file_name = 0x01
24 file_notify_change_dir_name = 0x02
25 file_notify_change_attributes = 0x04
26 file_notify_change_size = 0x08
27 file_notify_change_last_write = 0x10
28 file_notify_change_last_access = 0x20
29 file_notify_change_creation = 0x40
30 file_notify_change_security = 0x80
31)
32
33const (
34 file_action_added = 0x01
35 file_action_removed = 0x02
36 file_action_modified = 0x03
37 file_action_renamed_old_name = 0x04
38 file_action_renamed_new_name = 0x05
39)
40
41const (
42 file_attr_readonly = 0x00000001
43 file_attr_hidden = 0x00000002
44 file_attr_system = 0x00000004
45 file_attr_directory = 0x00000010
46 file_attr_archive = 0x00000020
47 file_attr_device = 0x00000040
48 file_attr_normal = 0x00000080
49 file_attr_temporary = 0x00000100
50 file_attr_sparse_file = 0x00000200
51 file_attr_reparse_point = 0x00000400
52 file_attr_compressed = 0x00000800
53 file_attr_offline = 0x00001000
54 file_attr_not_content_indexed = 0x00002000
55 file_attr_encrypted = 0x00004000
56 file_attr_integrity_stream = 0x00008000
57 file_attr_virtual = 0x00010000
58 file_attr_no_scrub_data = 0x00020000
59 // file_attr_recall_on_open = u32(0x...)
60 // file_attr_recall_on_data_access = u32(0x...)
61)
62
63const (
64 file_type_unknown = 0x00
65 file_type_disk = 0x01
66 file_type_char = 0x02
67 file_type_pipe = 0x03
68)
69
70const (
71 file_invalid_file_id = (-1)
72)
73
74const (
75 invalid_handle_value = voidptr(-1)
76)
77
78// https://docs.microsoft.com/en-us/windows/console/setconsolemode
79const (
80 // Input Buffer
81 enable_echo_input = 0x0004
82 enable_extended_flags = 0x0080
83 enable_insert_mode = 0x0020
84 enable_line_input = 0x0002
85 enable_mouse_input = 0x0010
86 enable_processed_input = 0x0001
87 enable_quick_edit_mode = 0x0040
88 enable_window_input = 0x0008
89 enable_virtual_terminal_input = 0x0200
90 // Output Screen Buffer
91 enable_processed_output = 0x01
92 enable_wrap_at_eol_output = 0x02
93 enable_virtual_terminal_processing = 0x04
94 disable_newline_auto_return = 0x08
95 enable_lvb_grid_worldwide = 0x10
96)
97
98// File modes
99const (
100 o_rdonly = 0x0000 // open the file read-only.
101 o_wronly = 0x0001 // open the file write-only.
102 o_rdwr = 0x0002 // open the file read-write.
103 o_append = 0x0008 // append data to the file when writing.
104 o_create = 0x0100 // create a new file if none exists.
105 o_binary = 0x8000 // input and output is not translated.
106 o_trunc = 0x0200 // truncate regular writable file when opened.
107 o_excl = 0x0400 // used with o_create, file must not exist.
108 o_sync = 0x0000 // open for synchronous I/O (ignored on Windows)
109 o_noctty = 0x0000 // make file non-controlling tty (ignored on Windows)
110 o_nonblock = 0x0000 // don't block on opening file (ignored on Windows)
111)
112
113const (
114 status_access_violation = u32(0xC0000005)
115 status_in_page_error = u32(0xC0000006)
116 status_invalid_handle = u32(0xC0000008)
117 status_invalid_parameter = u32(0xC000000D)
118 status_no_memory = u32(0xC0000017)
119 status_illegal_instruction = u32(0xC000001D)
120 status_noncontinuable_exception = u32(0xC0000025)
121 status_invalid_disposition = u32(0xC0000026)
122 status_array_bounds_exceeded = u32(0xC000008C)
123 status_float_denormal_operand = u32(0xC000008D)
124 status_float_divide_by_zero = u32(0xC000008E)
125 status_float_inexact_result = u32(0xC000008F)
126 status_float_invalid_operation = u32(0xC0000090)
127 status_float_overflow = u32(0xC0000091)
128 status_float_stack_check = u32(0xC0000092)
129 status_float_underflow = u32(0xC0000093)
130 status_integer_divide_by_zero = u32(0xC0000094)
131 status_integer_overflow = u32(0xC0000095)
132 status_privileged_instruction = u32(0xC0000096)
133 status_stack_overflow = u32(0xC00000FD)
134 status_dll_not_found = u32(0xC0000135)
135 status_ordinal_not_found = u32(0xC0000138)
136 status_entrypoint_not_found = u32(0xC0000139)
137 status_control_c_exit = u32(0xC000013A)
138 status_dll_init_failed = u32(0xC0000142)
139 status_float_multiple_faults = u32(0xC00002B4)
140 status_float_multiple_traps = u32(0xC00002B5)
141 status_reg_nat_consumption = u32(0xC00002C9)
142 status_heap_corruption = u32(0xC0000374)
143 status_stack_buffer_overrun = u32(0xC0000409)
144 status_invalid_cruntime_parameter = u32(0xC0000417)
145 status_assertion_failure = u32(0xC0000420)
146)
147
148// Windows Registry Constants
149pub const (
150 hkey_local_machine = voidptr(0x80000002)
151 hkey_current_user = voidptr(0x80000001)
152 key_query_value = 0x0001
153 key_set_value = 0x0002
154 key_enumerate_sub_keys = 0x0008
155 key_wow64_32key = 0x0200
156)
157
158// Windows Messages
159pub const (
160 hwnd_broadcast = voidptr(0xFFFF)
161 wm_settingchange = 0x001A
162 smto_abortifhung = 0x0002
163)