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