]> git.lizzy.rs Git - rust.git/blob - library/std/src/sys/unsupported/os.rs
Rollup merge of #84320 - jsha:details-implementors, r=Manishearth,Nemo157,GuillaumeGomez
[rust.git] / library / std / src / sys / unsupported / os.rs
1 use super::unsupported;
2 use crate::error::Error as StdError;
3 use crate::ffi::{OsStr, OsString};
4 use crate::fmt;
5 use crate::io;
6 use crate::marker::PhantomData;
7 use crate::path::{self, PathBuf};
8
9 pub fn errno() -> i32 {
10     0
11 }
12
13 pub fn error_string(_errno: i32) -> String {
14     "operation successful".to_string()
15 }
16
17 pub fn getcwd() -> io::Result<PathBuf> {
18     unsupported()
19 }
20
21 pub fn chdir(_: &path::Path) -> io::Result<()> {
22     unsupported()
23 }
24
25 pub struct SplitPaths<'a>(!, PhantomData<&'a ()>);
26
27 pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> {
28     panic!("unsupported")
29 }
30
31 impl<'a> Iterator for SplitPaths<'a> {
32     type Item = PathBuf;
33     fn next(&mut self) -> Option<PathBuf> {
34         self.0
35     }
36 }
37
38 #[derive(Debug)]
39 pub struct JoinPathsError;
40
41 pub fn join_paths<I, T>(_paths: I) -> Result<OsString, JoinPathsError>
42 where
43     I: Iterator<Item = T>,
44     T: AsRef<OsStr>,
45 {
46     Err(JoinPathsError)
47 }
48
49 impl fmt::Display for JoinPathsError {
50     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
51         "not supported on this platform yet".fmt(f)
52     }
53 }
54
55 impl StdError for JoinPathsError {
56     #[allow(deprecated)]
57     fn description(&self) -> &str {
58         "not supported on this platform yet"
59     }
60 }
61
62 pub fn current_exe() -> io::Result<PathBuf> {
63     unsupported()
64 }
65
66 pub struct Env(!);
67
68 impl Iterator for Env {
69     type Item = (OsString, OsString);
70     fn next(&mut self) -> Option<(OsString, OsString)> {
71         self.0
72     }
73 }
74
75 pub fn env() -> Env {
76     panic!("not supported on this platform")
77 }
78
79 pub fn getenv(_: &OsStr) -> io::Result<Option<OsString>> {
80     Ok(None)
81 }
82
83 pub fn setenv(_: &OsStr, _: &OsStr) -> io::Result<()> {
84     Err(io::Error::new_const(io::ErrorKind::Unsupported, &"cannot set env vars on this platform"))
85 }
86
87 pub fn unsetenv(_: &OsStr) -> io::Result<()> {
88     Err(io::Error::new_const(io::ErrorKind::Unsupported, &"cannot unset env vars on this platform"))
89 }
90
91 pub fn temp_dir() -> PathBuf {
92     panic!("no filesystem on this platform")
93 }
94
95 pub fn home_dir() -> Option<PathBuf> {
96     None
97 }
98
99 pub fn exit(_code: i32) -> ! {
100     crate::intrinsics::abort()
101 }
102
103 pub fn getpid() -> u32 {
104     panic!("no pids on this platform")
105 }