From 2c5a660c99168c99bd9ba40a47afe637497c7e0e Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 6 Jun 2012 21:39:41 -0700 Subject: [PATCH] core: Add os::family. Returns either 'windows' or 'unix' --- src/libcore/os.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libcore/os.rs b/src/libcore/os.rs index e14b731da86..d2d6f48bceb 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -28,7 +28,7 @@ export close, fclose, fsync_fd, waitpid; export env, getenv, setenv, fdopen, pipe; export getcwd, dll_filename, self_exe_path; -export exe_suffix, dll_suffix, sysname, arch; +export exe_suffix, dll_suffix, sysname, arch, family; export homedir, list_dir, list_dir_path, path_is_dir, path_exists, make_absolute, make_dir, remove_dir, change_dir, remove_file, copy_file; @@ -755,6 +755,14 @@ fn set_exit_status(code: int) { rustrt::rust_set_exit_status(code as libc::intptr_t); } +#[cfg(target_os = "macos")] +#[cfg(target_os = "linux")] +#[cfg(target_os = "freebsd")] +fn family() -> str { "unix" } + +#[cfg(target_os = "win32")] +fn family() -> str { "windows" } + #[cfg(target_os = "macos")] mod consts { fn sysname() -> str { "macos" }