package core:os/old
Overview
The original implementation of core:os, to be removed in Q2 2026.
Cross-platform OS interactions like file I/O.
Index
Constants (55)
- ENDIAN
- ERROR_ACCESS_DENIED
- ERROR_ALREADY_EXISTS
- ERROR_BROKEN_PIPE
- ERROR_BUFFER_OVERFLOW
- ERROR_DIR_NOT_EMPTY
- ERROR_FILE_EXISTS
- ERROR_FILE_IS_NOT_DIR
- ERROR_FILE_IS_PIPE
- ERROR_FILE_NOT_FOUND
- ERROR_HANDLE_EOF
- ERROR_INSUFFICIENT_BUFFER
- ERROR_INVALID_PARAMETER
- ERROR_IO_PENDING
- ERROR_MOD_NOT_FOUND
- ERROR_MORE_DATA
- ERROR_NEGATIVE_SEEK
- ERROR_NETNAME_DELETED
- ERROR_NOT_ENOUGH_MEMORY
- ERROR_NOT_ENOUGH_MEMORY
- ERROR_NOT_FOUND
- ERROR_NO_MORE_FILES
- ERROR_OPERATION_ABORTED
- ERROR_PATH_NOT_FOUND
- File_Mode
- File_Mode_Char_Device
- File_Mode_Device
- File_Mode_Dir
- File_Mode_Named_Pipe
- File_Mode_Named_Pipe
- File_Mode_Sym_Link
- INVALID_HANDLE
- O_APPEND
- O_APPEND
- O_ASYNC
- O_CLOEXEC
- O_CREATE
- O_EXCL
- O_NOCTTY
- O_RDONLY
- O_RDONLY
- O_RDWR
- O_SYNC
- O_TRUNC
- O_WRONLY
- SEEK_CUR
- SEEK_END
- WSAEACCES
- WSAECONNRESET
- cleanpath_from_buf
- cleanpath_from_buf
- clear_env
- get_last_error
- open
- unset_env
Procedures (75)
- ERROR_FILE_EXISTS
- ERROR_FILE_NOT_FOUND
- ERROR_HANDLE_EOF
- ERROR_INVALID_HANDLE
- ERROR_MOD_NOT_FOUND
- File_Mode_Named_Pipe
- O_EXCL
- WSAECONNRESET
- change_directory
- close
- close
- current_thread_id
- current_thread_id
- environ
- environ
- error_string
- exists
- exit
- file_info_delete
- file_info_from_win32_file_attribute_data
- file_info_slice_delete
- file_size
- file_size_from_path
- flush
- fstat
- ftruncate
- get_env_buf
- get_page_size
- get_windows_version_w
- heap_allocator_proc
- is_dir
- is_file
- is_path_separator
- is_platform_error
- is_windows_11
- is_windows_7
- is_windows_7
- is_windows_8
- is_windows_8_1
- is_windows_xp
- last_write_time
- link
- lookup_env_alloc
- lookup_env_buffer
- lstat
- lstat
- make_directory
- open
- processor_core_count
- read
- read_at
- read_entire_file_from_filename
- read_entire_file_from_filename_or_err
- read_entire_file_from_handle
- read_ptr
- remove
- remove
- remove_directory
- rename
- replace_environment_placeholders
- seek
- set_current_directory
- set_env
- stat
- stdin
- stream_from_handle
- windows_set_file_info_times
- write
- write_byte
- write_encoded_rune
- write_encoded_rune
- write_entire_file_or_err
- write_ptr
- write_rune
- write_string
Procedure Groups (4)
Types
ERROR_ACCESS_DENIED ¶
ERROR_ACCESS_DENIED :: Handle
Related Procedures With Parameters
- close
- file_size
- flush
- fstat
- ftruncate
- last_write_time
- print_error
- read
- read_at
- read_at_least
- read_dir
- read_entire_file_from_handle
- read_entire_file_from_handle_or_err
- read_full
- read_ptr
- seek
- stream_from_handle
- write
- write_at
- write_byte
- write_encoded_rune
- write_ptr
- write_rune
- write_string
- read_entire_file (procedure groups)
- read_entire_file_or_err (procedure groups)
Related Procedures With Returns
Related Constants
Errno ¶
Errno :: Error
alias for legacy use
Related Procedures With Parameters
Related Procedures With Returns
- close
- file_size
- flush
- fstat
- ftruncate
- get_last_error
- last_write_time
- last_write_time_by_name
- link
- lookup_env_buffer
- lstat
- make_directory
- open
- pipe
- read
- read_at
- read_at_least
- read_dir
- read_entire_file_from_filename_or_err
- read_entire_file_from_handle_or_err
- read_full
- read_ptr
- remove
- remove_directory
- rename
- seek
- set_current_directory
- set_env
- stat
- truncate
- unlink
- unset_env
- write
- write_at
- write_byte
- write_encoded_rune
- write_entire_file_or_err
- write_ptr
- write_rune
- write_string
- lookup_env (procedure groups)
- read_entire_file_or_err (procedure groups)
Related Constants
Error ¶
Error :: union { General_Error, io.Error, runtime.Allocator_Error, sys_windows.System_Error, }
Related Procedures With Parameters
Related Procedures With Returns
- close
- file_size
- flush
- fstat
- ftruncate
- get_last_error
- last_write_time
- last_write_time_by_name
- link
- lookup_env_buffer
- lstat
- make_directory
- open
- pipe
- read
- read_at
- read_at_least
- read_dir
- read_entire_file_from_filename_or_err
- read_entire_file_from_handle_or_err
- read_full
- read_ptr
- remove
- remove_directory
- rename
- seek
- set_current_directory
- set_env
- stat
- truncate
- unlink
- unset_env
- write
- write_at
- write_byte
- write_encoded_rune
- write_entire_file_or_err
- write_ptr
- write_rune
- write_string
- lookup_env (procedure groups)
- read_entire_file_or_err (procedure groups)
Related Constants
File_Info ¶
File_Info :: struct { fullpath: string, // allocated name: string, // uses `fullpath` as underlying data size: i64, mode: File_Mode, is_dir: bool, creation_time: time.Time, modification_time: time.Time, access_time: time.Time, }
Related Procedures With Parameters
General_Error ¶
General_Error :: enum u32 { None, Exist, Not_Exist, Timeout, Broken_Pipe, Invalid_File, Invalid_Dir, Invalid_Path, Invalid_Callback, Pattern_Has_Separator, File_Is_Pipe, Not_Dir, // Environment variable not found. Env_Var_Not_Found, }
Related Constants
Platform_Error ¶
Platform_Error :: sys_windows.System_Error
Related Constants
- ERROR_ACCESS_DENIED
- ERROR_ALREADY_EXISTS
- ERROR_BROKEN_PIPE
- ERROR_BUFFER_OVERFLOW
- ERROR_DIR_NOT_EMPTY
- ERROR_ENVVAR_NOT_FOUND
- ERROR_FILE_EXISTS
- ERROR_FILE_NOT_FOUND
- ERROR_HANDLE_EOF
- ERROR_INSUFFICIENT_BUFFER
- ERROR_INVALID_HANDLE
- ERROR_INVALID_PARAMETER
- ERROR_IO_PENDING
- ERROR_MOD_NOT_FOUND
- ERROR_MORE_DATA
- ERROR_NEGATIVE_SEEK
- ERROR_NETNAME_DELETED
- ERROR_NOT_ENOUGH_MEMORY
- ERROR_NOT_FOUND
- ERROR_NO_MORE_FILES
- ERROR_OPERATION_ABORTED
- ERROR_PATH_NOT_FOUND
- ERROR_PRIVILEGE_NOT_HELD
- ERROR_PROC_NOT_FOUND
- WSAEACCES
- WSAECONNRESET
Constants
ENDIAN ¶
ENDIAN: .Odin_Endian_Type : ODIN_ENDIAN
ERROR_ACCESS_DENIED ¶
ERROR_ACCESS_DENIED :: ERROR_PROC_NOT_FOUND
ERROR_ALREADY_EXISTS ¶
ERROR_ALREADY_EXISTS: sys_windows.System_Error : _Platform_Error(183)
ERROR_BROKEN_PIPE ¶
ERROR_BROKEN_PIPE: sys_windows.System_Error : _Platform_Error(109)
ERROR_BUFFER_OVERFLOW ¶
ERROR_BUFFER_OVERFLOW: sys_windows.System_Error : _Platform_Error(111)
ERROR_DIR_NOT_EMPTY ¶
ERROR_DIR_NOT_EMPTY: sys_windows.System_Error : _Platform_Error(145)
ERROR_FILE_EXISTS ¶
ERROR_FILE_EXISTS: sys_windows.System_Error : _Platform_Error(80)
ERROR_FILE_IS_NOT_DIR ¶
ERROR_FILE_IS_NOT_DIR :: General_Error.Not_Dir
ERROR_FILE_IS_PIPE ¶
ERROR_FILE_IS_PIPE :: General_Error.File_Is_Pipe
ERROR_FILE_NOT_FOUND ¶
ERROR_FILE_NOT_FOUND: sys_windows.System_Error : _Platform_Error(2)
ERROR_HANDLE_EOF ¶
ERROR_HANDLE_EOF: sys_windows.System_Error : _Platform_Error(38)
ERROR_INSUFFICIENT_BUFFER ¶
ERROR_INSUFFICIENT_BUFFER: sys_windows.System_Error : _Platform_Error(122)
ERROR_INVALID_PARAMETER ¶
ERROR_INVALID_PARAMETER: sys_windows.System_Error : _Platform_Error(87)
ERROR_IO_PENDING ¶
ERROR_IO_PENDING: sys_windows.System_Error : _Platform_Error(997)
ERROR_MOD_NOT_FOUND ¶
ERROR_MOD_NOT_FOUND: sys_windows.System_Error : _Platform_Error(126)
ERROR_MORE_DATA ¶
ERROR_MORE_DATA: sys_windows.System_Error : _Platform_Error(234)
ERROR_NEGATIVE_SEEK ¶
ERROR_NEGATIVE_SEEK: sys_windows.System_Error : _Platform_Error(131)
ERROR_NETNAME_DELETED ¶
ERROR_NETNAME_DELETED: sys_windows.System_Error : _Platform_Error(64)
ERROR_NOT_ENOUGH_MEMORY ¶
ERROR_NOT_ENOUGH_MEMORY: sys_windows.System_Error : _Platform_Error(8)
ERROR_NOT_ENOUGH_MEMORY ¶
ERROR_NOT_ENOUGH_MEMORY :: SEEK_SET
ERROR_NOT_FOUND ¶
ERROR_NOT_FOUND: sys_windows.System_Error : _Platform_Error(1168)
ERROR_NO_MORE_FILES ¶
ERROR_NO_MORE_FILES: sys_windows.System_Error : _Platform_Error(18)
ERROR_OPERATION_ABORTED ¶
ERROR_OPERATION_ABORTED: sys_windows.System_Error : _Platform_Error(995)
ERROR_PATH_NOT_FOUND ¶
ERROR_PATH_NOT_FOUND: sys_windows.System_Error : _Platform_Error(3)
File_Mode ¶
File_Mode :: OS
File_Mode_Char_Device ¶
File_Mode_Char_Device :: File_Mode(1 << 19)
File_Mode_Device ¶
File_Mode_Device :: File_Mode(1 << 18)
File_Mode_Dir ¶
File_Mode_Dir :: File_Mode(1 << 16)
File_Mode_Named_Pipe ¶
File_Mode_Named_Pipe :: WINDOWS_11_BUILD_CUTOFF
Windows 11 (preview) has the same major and minor version numbers as Windows 10: 10 and 0 respectively. To determine if you're on Windows 10 or 11, we need to look at the build number. As far as we can tell right now, the cutoff is build 22_000. TODO: Narrow down this range once Win 11 is published and the last Win 10 builds
become available.
File_Mode_Named_Pipe ¶
File_Mode_Named_Pipe :: File_Mode(1 << 17)
File_Mode_Sym_Link ¶
File_Mode_Sym_Link :: File_Mode(1 << 20)
INVALID_HANDLE ¶
INVALID_HANDLE: Handle : ~Handle(0)
O_APPEND ¶
O_APPEND :: 0x00400
O_APPEND ¶
O_APPEND :: ERROR_ENVVAR_NOT_FOUND
O_CLOEXEC ¶
O_CLOEXEC :: 0x80000
O_CREATE ¶
O_CREATE :: ERROR_INVALID_HANDLE
O_NOCTTY ¶
O_NOCTTY :: 0x00100
O_RDONLY ¶
O_RDONLY :: O_NONBLOCK
O_RDONLY ¶
O_RDONLY :: 0x00000
O_WRONLY ¶
O_WRONLY :: 0x00001
SEEK_CUR ¶
SEEK_CUR :: 1
SEEK_END ¶
SEEK_END :: 2
WSAEACCES ¶
WSAEACCES: sys_windows.System_Error : _Platform_Error(10013)
WSAECONNRESET ¶
WSAECONNRESET: sys_windows.System_Error : _Platform_Error(10054)
cleanpath_from_buf ¶
cleanpath_from_buf :: ERROR_EOF
cleanpath_from_buf ¶
cleanpath_from_buf :: ERROR_NONE
clear_env ¶
clear_env :: ERROR_PRIVILEGE_NOT_HELD
get_last_error ¶
get_last_error :: ERROR_ACCESS_DENIED
unset_env ¶
unset_env :: O_CREATE
Variables
Procedures
ERROR_FILE_EXISTS ¶
ERROR_FILE_EXISTS :: get_last_error
ERROR_FILE_NOT_FOUND ¶
ERROR_FILE_NOT_FOUND :: last_write_time_by_name
ERROR_HANDLE_EOF ¶
ERROR_HANDLE_EOF :: is_windows_10
ERROR_INVALID_HANDLE ¶
ERROR_INVALID_HANDLE :: read_dir
ERROR_MOD_NOT_FOUND ¶
ERROR_MOD_NOT_FOUND :: write_entire_file
File_Mode_Named_Pipe ¶
File_Mode_Named_Pipe :: unlink
O_EXCL ¶
O_EXCL :: print_error
WSAECONNRESET ¶
WSAECONNRESET :: write_encoded_rune
change_directory ¶
change_directory :: set_current_directory
close ¶
close :: write_byte
current_thread_id ¶
current_thread_id :: get_current_directory
current_thread_id ¶
current_thread_id :: proc "contextless" () -> int {…}
environ ¶
environ :: proc(allocator := context.allocator) -> []string {…}
environ returns a copy of strings representing the environment, in the form "key=value" NOTE: the slice of strings and the strings with be allocated using the supplied allocator
file_info_delete ¶
file_info_delete :: proc(fi: File_Info, allocator := context.allocator) {…}
file_info_from_win32_file_attribute_data ¶
file_info_from_win32_file_attribute_data :: write_at
file_info_slice_delete ¶
file_info_slice_delete :: proc(infos: []File_Info, allocator := context.allocator) {…}
fstat ¶
fstat :: proc(fd: Handle, allocator := context.allocator) -> (fi: File_Info, err: Error) {…}
get_env_buf ¶
Related Procedure Groups
get_page_size ¶
get_page_size :: proc() -> int {…}
get_windows_version_w ¶
get_windows_version_w :: proc "contextless" () -> sys_windows.OSVERSIONINFOEXW {…}
heap_allocator_proc ¶
heap_allocator_proc :: unset_env
unset_env unsets a single environment variable
is_windows_11 ¶
is_windows_11 :: proc "contextless" () -> bool {…}
is_windows_7 ¶
is_windows_7 :: pipe
is_windows_7 ¶
is_windows_7 :: proc "contextless" () -> bool {…}
is_windows_8 ¶
is_windows_8 :: proc "contextless" () -> bool {…}
is_windows_8_1 ¶
is_windows_8_1 :: proc "contextless" () -> bool {…}
is_windows_xp ¶
is_windows_xp :: get_env_alloc
get_env retrieves the value of the environment variable named by the key It returns the value, which will be empty if the variable is not present To distinguish between an empty value and an unset value, use lookup_env NOTE: the value will be allocated with the supplied allocator
Related Procedure Groups
lookup_env_alloc ¶
lookup_env_alloc :: proc(key: string, allocator := context.allocator) -> (value: string, found: bool) {…}
lookup_env gets the value of the environment variable named by the key If the variable is found in the environment the value (which can be empty) is returned and the boolean is true Otherwise the returned value will be empty and the boolean will be false NOTE: the value will be allocated with the supplied allocator
Related Procedure Groups
lookup_env_buffer ¶
This version of lookup_env doesn't allocate and instead requires the user to provide a buffer.
Note that it is limited to environment names and values of 512 utf-16 values each
due to the necessary utf-8 <> utf-16 conversion.
Related Procedure Groups
lstat ¶
lstat :: is_windows_vista
processor_core_count ¶
processor_core_count :: proc() -> int {…}
read_at ¶
read_at returns n: 0, err: 0 on EOF
read_entire_file_from_filename ¶
read_entire_file_from_filename :: proc(name: string, allocator := context.allocator, loc := #caller_location) -> (data: []u8, success: bool) {…}
Related Procedure Groups
read_entire_file_from_filename_or_err ¶
read_entire_file_from_filename_or_err :: proc(name: string, allocator := context.allocator, loc := #caller_location) -> (data: []u8, err: Error) {…}
Related Procedure Groups
read_entire_file_from_handle ¶
read_entire_file_from_handle :: proc(fd: Handle, allocator := context.allocator, loc := #caller_location) -> (data: []u8, success: bool) {…}
Related Procedure Groups
remove ¶
remove :: read_at_least
replace_environment_placeholders ¶
replace_environment_placeholders :: proc(path: string, allocator := context.allocator) -> (res: string) {…}
Always allocates for consistency.
set_env ¶
set_env sets the value of the environment variable named by the key
windows_set_file_info_times ¶
windows_set_file_info_times :: is_windows_xp
write_byte ¶
write_byte :: get_std_handle
write_encoded_rune ¶
write_encoded_rune :: truncate
write_encoded_rune ¶
write_encoded_rune :: read_full
Procedure Groups
get_current_directory ¶
get_current_directory :: read_entire_file_or_err
get_env ¶
get_env :: proc{ get_env_alloc, get_env_buf, }
lookup_env ¶
lookup_env :: proc{ lookup_env_alloc, lookup_env_buffer, }
read_entire_file ¶
read_entire_file :: proc{ read_entire_file_from_filename, read_entire_file_from_handle, }
Source Files
- doc.odin
- errors.odin
- os.odin
- stat.odin
- stream.odin
- (hidden platform specific files)
Generation Information
Generated with odin version dev-2026-03 (vendor "odin") Windows_amd64 @ 2026-03-16 21:30:54.665907900 +0000 UTC