1 use crate::error::Error as StdError;
2 use crate::ffi::{OsString, OsStr};
5 use crate::path::{self, PathBuf};
7 use crate::sys::{unsupported, Void, ExitSysCall, GetEnvSysCall, SetEnvSysCall};
9 pub fn errno() -> i32 {
13 pub fn error_string(_errno: i32) -> String {
14 "operation successful".to_string()
17 pub fn getcwd() -> io::Result<PathBuf> {
21 pub fn chdir(_: &path::Path) -> io::Result<()> {
25 pub struct SplitPaths<'a>(&'a Void);
27 pub fn split_paths(_unparsed: &OsStr) -> SplitPaths {
31 impl<'a> Iterator for SplitPaths<'a> {
33 fn next(&mut self) -> Option<PathBuf> {
39 pub struct JoinPathsError;
41 pub fn join_paths<I, T>(_paths: I) -> Result<OsString, JoinPathsError>
42 where I: Iterator<Item=T>, T: AsRef<OsStr>
47 impl fmt::Display for JoinPathsError {
48 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
49 "not supported on wasm yet".fmt(f)
53 impl StdError for JoinPathsError {
54 fn description(&self) -> &str {
55 "not supported on wasm yet"
59 pub fn current_exe() -> io::Result<PathBuf> {
65 impl Iterator for Env {
66 type Item = (OsString, OsString);
67 fn next(&mut self) -> Option<(OsString, OsString)> {
73 panic!("not supported on web assembly")
76 pub fn getenv(k: &OsStr) -> io::Result<Option<OsString>> {
77 Ok(GetEnvSysCall::perform(k))
80 pub fn setenv(k: &OsStr, v: &OsStr) -> io::Result<()> {
81 Ok(SetEnvSysCall::perform(k, Some(v)))
84 pub fn unsetenv(k: &OsStr) -> io::Result<()> {
85 Ok(SetEnvSysCall::perform(k, None))
88 pub fn temp_dir() -> PathBuf {
89 panic!("no filesystem on wasm")
92 pub fn home_dir() -> Option<PathBuf> {
96 pub fn exit(_code: i32) -> ! {
97 ExitSysCall::perform(_code as isize as usize)
100 pub fn getpid() -> u32 {
101 panic!("no pids on wasm")