1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 use error::Error as StdError;
12 use ffi::{OsString, OsStr};
15 use path::{self, PathBuf};
17 use sys::{unsupported, Void, ExitSysCall, GetEnvSysCall, SetEnvSysCall};
19 pub fn errno() -> i32 {
23 pub fn error_string(_errno: i32) -> String {
24 format!("operation successful")
27 pub fn getcwd() -> io::Result<PathBuf> {
31 pub fn chdir(_: &path::Path) -> io::Result<()> {
35 pub struct SplitPaths<'a>(&'a Void);
37 pub fn split_paths(_unparsed: &OsStr) -> SplitPaths {
41 impl<'a> Iterator for SplitPaths<'a> {
43 fn next(&mut self) -> Option<PathBuf> {
49 pub struct JoinPathsError;
51 pub fn join_paths<I, T>(_paths: I) -> Result<OsString, JoinPathsError>
52 where I: Iterator<Item=T>, T: AsRef<OsStr>
57 impl fmt::Display for JoinPathsError {
58 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
59 "not supported on wasm yet".fmt(f)
63 impl StdError for JoinPathsError {
64 fn description(&self) -> &str {
65 "not supported on wasm yet"
69 pub fn current_exe() -> io::Result<PathBuf> {
75 impl Iterator for Env {
76 type Item = (OsString, OsString);
77 fn next(&mut self) -> Option<(OsString, OsString)> {
83 panic!("not supported on web assembly")
86 pub fn getenv(k: &OsStr) -> io::Result<Option<OsString>> {
87 Ok(GetEnvSysCall::perform(k))
90 pub fn setenv(k: &OsStr, v: &OsStr) -> io::Result<()> {
91 Ok(SetEnvSysCall::perform(k, Some(v)))
94 pub fn unsetenv(k: &OsStr) -> io::Result<()> {
95 Ok(SetEnvSysCall::perform(k, None))
98 pub fn temp_dir() -> PathBuf {
99 panic!("no filesystem on wasm")
102 pub fn home_dir() -> Option<PathBuf> {
106 pub fn exit(_code: i32) -> ! {
107 ExitSysCall::perform(_code as isize as usize)
110 pub fn getpid() -> u32 {
111 panic!("no pids on wasm")