Module std::os

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.

Reexports

pub use os::consts::*;
pub use libc::libc::fclose;

Modules

consts

Structs

MemoryMap
Pipe

Enums

MapError
MapOption
MemoryMapKind

Statics

pub static TMPBUF_SZ: uint = 1000u  

Functions

args

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

change_dir

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

close

Delegates to the libc close() function, returning the same return value.

copy_file

Copies a file from one location to another

dll_filename

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

env

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

errno

Returns the platform-specific value of errno

fdopen
fill_charp_buf
fsync_fd
getcwd
getenv

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

homedir

Returns the path to the user's home directory, if known.

last_os_error

Get a string representing the platform-dependent last error

list_dir

Lists the contents of a directory

list_dir_path

Lists the contents of a directory

make_absolute

Convert a relative path to an absolute path

make_dir

Creates a directory at the specified path

mkdir_recursive

Creates a directory with a given mode. Returns true iff creation succeeded. Also creates all intermediate subdirectories if they don't already exist, giving all of them the same mode.

page_size
path_exists

Indicates whether a path exists

path_is_dir

Indicates whether a path represents a directory

pipe
remove_dir

Removes a directory at the specified path

remove_dir_recursive

Removes a directory at the specified path, after removing all its contents. Use carefully!

remove_file

Deletes an existing file

rename_file

Renames an existing file or directory

self_exe_path

Optionally returns the filesystem path to the current executable which is running. If any failure occurs, None is returned.

set_exit_status

Sets the process exit code

setenv

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

tmpdir

Returns the path to a temporary directory.

unsetenv

Remove a variable from the environment entirely

walk_dir

Recursively walk a directory structure