Import with #import "std/file_linux".

FileHandle :: struct { fd: s32; valid: bool; }
DirectoryCursor :: struct { storage: *void; valid: bool; failed: bool; }
DirectoryKind :: enum { Unknown = 0; Directory = 4; Regular = 8; Link = 10; Other = 255; }
DirectoryEntry :: struct { name: [256]u8; name_count: s32; valid: bool; kind: DirectoryKind; }
OpenRead :: (path: string) -> FileHandle
OpenUpdate :: (path: string) -> FileHandle
OpenWrite :: (path: string) -> FileHandle
OpenReplace :: (path: string) -> FileHandle
OpenNew :: (path: string) -> FileHandle

Create a writable file only when the path is unoccupied, including by a symbolic link. Creation is exclusive in the same native open operation.

OpenExclusivePrivate :: (path: string) -> FileHandle
RemoveFile :: (path: string) -> bool
PathExists :: (path: string) -> bool
DirectoryExists :: (path: string) -> bool
RenamePath :: (source: string, destination: string) -> bool
RenameNoReplace :: (source: string, destination: string) -> bool
LinkFile :: (source: string, destination: string) -> bool
CreateDirectory :: (path: string) -> bool
CreatePrivateDirectory :: (path: string) -> bool
FileSize :: (file: FileHandle) -> s64
ReadAt :: (file: FileHandle, output: []u8, offset: s64) -> s64
WriteAt :: (file: FileHandle, input: []u8, offset: s64) -> s64
WriteTextAt :: (file: FileHandle, input: string, offset: s64) -> s64

Copy immutable text through a bounded buffer before writing it. The string may borrow read-only storage, so it must not be exposed as a mutable slice.

CloseFile :: (file: FileHandle) -> bool
SyncFile :: (file: FileHandle) -> bool
Read :: (file: FileHandle, output: []u8) -> s64
Write :: (file: FileHandle, input: []u8) -> s64
OpenDirectory :: (path: string) -> DirectoryCursor
NextDirectoryEntry :: (cursor: *DirectoryCursor) -> DirectoryEntry
CloseDirectory :: (cursor: *DirectoryCursor) -> bool

Source ↗ · All modules