Module std::osUnstable [-] [+] [src]

Higher-level interfaces to libc::* functions and operating system services.

In general these take and return rust types, use rust idioms (enums, closures, vectors) rather than C idioms, and do more extensive safety checks.

This module is not meant to only contain 1:1 mappings to libc entries; any os-interface code that is reasonably useful and broadly applicable can go here. Including utility routines that merely build on other os code.

We assume the general case is that users do not care, and do not want to be made to care, which operating system they are on. While they may want to special case various special cases -- and so we will not hide the facts of which OS the user is on -- they should be given the opportunity to write OS-ignorant code by default.

Modules

consts
unix

Experimental extensions to std for Unix platforms.

Structs

MemoryMap

A memory mapped file or chunk of memory. This is a very system-specific interface to the OS's memory mapping facilities (mmap on POSIX, VirtualAlloc/CreateFileMapping on Windows). It makes no attempt at abstracting platform differences, besides in error values returned. Consider yourself warned.

Pipe

A low-level OS in-memory pipe.

Enums

MapError

Possible errors when creating a map.

MapOption

Options the memory map is created with

MemoryMapKind

Type of memory map

Constants

TMPBUF_SZ

Functions

args

Returns the arguments which this program was started with (normally passed via the command line).

args_as_bytes

Returns the arguments which this program was started with (normally passed via the command line) as byte vectors.

change_dir

Changes the current working directory to the specified path, returning whether the change was completed successfully or not.

dll_filename

Returns the proper dll filename for the given basename of a file as a String.

env

Returns a vector of (variable, value) pairs, for all the environment variables of the current process.

env_as_bytes

Returns a vector of (variable, value) byte-vector pairs for all the environment variables of the current process.

errno

Returns the platform-specific value of errno

error_string

Return the string corresponding to an errno() value of errnum.

get_exit_status

Fetches the process's current exit code. This defaults to 0 and can change by calling set_exit_status.

getcwd

Returns the current working directory as a Path.

getenv

Fetches the environment variable n from the current process, returning None if the variable isn't set.

getenv_as_bytes

Fetches the environment variable n byte vector from the current process, returning None if the variable isn't set.

homedir

Optionally returns the path to the current user's home directory if known.

join_paths

Joins a collection of Paths appropriately for the PATH environment variable.

last_os_error

Get a string representing the platform-dependent last error

make_absolute

Convert a relative path to an absolute path

num_cpus

Get the number of cores available

page_size

Returns the page size of the current architecture in bytes.

pipe

Creates a new low-level OS in-memory pipe.

self_exe_name

Optionally returns the filesystem path to the current executable which is running but with the executable name.

self_exe_path

Optionally returns the filesystem path to the current executable which is running.

set_exit_status

Sets the process exit code

setenv

Sets the environment variable n to the value v for the currently running process.

split_paths

Parses input according to platform conventions for the PATH environment variable.

tmpdir

Returns the path to a temporary directory.

unsetenv

Remove a variable from the environment entirely.