diff options
| author | Ed Schouten <ed@nuxi.nl> | 2018-01-11 11:21:42 +0100 |
|---|---|---|
| committer | Ed Schouten <ed@nuxi.nl> | 2018-01-11 11:26:13 +0100 |
| commit | d882bb516e0998d7f9c2d049dcc618992a1a04c0 (patch) | |
| tree | 02370689e6220246902e84563623e84fb80c74a5 /src/libstd/sys/cloudabi/shims/os.rs | |
| parent | 20745264ce3298147067fcb46e1f51efcb9670e4 (diff) | |
| download | rust-d882bb516e0998d7f9c2d049dcc618992a1a04c0.tar.gz rust-d882bb516e0998d7f9c2d049dcc618992a1a04c0.zip | |
Add shims for modules that we can't implement on CloudABI.
As discussed in #47268, libstd isn't ready to have certain functionality disabled yet. Follow wasm's approach of adding no-op modules for all of the features that we can't implement. I've placed all of those shims in a shims/ subdirectory, so we (the CloudABI folks) can experiment with removing them more easily. It also ensures that the code that does work doesn't get polluted with lots of useless boilerplate code.
Diffstat (limited to 'src/libstd/sys/cloudabi/shims/os.rs')
| -rw-r--r-- | src/libstd/sys/cloudabi/shims/os.rs | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/src/libstd/sys/cloudabi/shims/os.rs b/src/libstd/sys/cloudabi/shims/os.rs new file mode 100644 index 00000000000..1e355d9ad04 --- /dev/null +++ b/src/libstd/sys/cloudabi/shims/os.rs @@ -0,0 +1,95 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use error::Error as StdError; +use ffi::{OsStr, OsString}; +use fmt; +use io; +use iter; +use path::{self, PathBuf}; +use sys::{unsupported, Void}; + +pub fn getcwd() -> io::Result<PathBuf> { + unsupported() +} + +pub fn chdir(_: &path::Path) -> io::Result<()> { + unsupported() +} + +pub type Env = iter::Empty<(OsString, OsString)>; + +pub fn env() -> Env { + iter::empty() +} + +pub fn getenv(_: &OsStr) -> io::Result<Option<OsString>> { + Ok(None) +} + +pub fn setenv(_: &OsStr, _: &OsStr) -> io::Result<()> { + unsupported() +} + +pub fn unsetenv(_: &OsStr) -> io::Result<()> { + unsupported() +} + +pub struct SplitPaths<'a>(&'a Void); + +pub fn split_paths(_unparsed: &OsStr) -> SplitPaths { + panic!("unsupported") +} + +impl<'a> Iterator for SplitPaths<'a> { + type Item = PathBuf; + fn next(&mut self) -> Option<PathBuf> { + match *self.0 {} + } +} + +#[derive(Debug)] +pub struct JoinPathsError; + +pub fn join_paths<I, T>(_paths: I) -> Result<OsString, JoinPathsError> +where + I: Iterator<Item = T>, + T: AsRef<OsStr>, +{ + Err(JoinPathsError) +} + +impl fmt::Display for JoinPathsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + "not supported on CloudABI yet".fmt(f) + } +} + +impl StdError for JoinPathsError { + fn description(&self) -> &str { + "not supported on CloudABI yet" + } +} + +pub fn home_dir() -> Option<PathBuf> { + None +} + +pub fn temp_dir() -> PathBuf { + PathBuf::from("/tmp") +} + +pub fn current_exe() -> io::Result<PathBuf> { + unsupported() +} + +pub fn getpid() -> u32 { + 1 +} |
