#![warn(missing_docs)]
extern crate xdg;
#[cfg(all(unix, target_os = "macos"))]
mod osx;
#[cfg(all(unix, not(target_os = "macos")))]
mod unix;
#[cfg(windows)]
mod windows;
#[cfg(all(unix, target_os = "macos"))]
use osx as platform;
#[cfg(all(unix, not(target_os = "macos")))]
use unix as platform;
#[cfg(windows)]
use windows as platform;
use std::error;
use std::fmt;
use std::path::Path;
use std::path::PathBuf;
#[derive(Debug)]
pub struct Error {
_unused: (),
}
impl Error {
fn new() -> Error {
Error {
_unused: (),
}
}
}
impl error::Error for Error {
fn description(&self) -> &str {
"error getting configuration directories"
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
error::Error::description(self).fmt(f)
}
}
pub type Result<T> = std::result::Result<T, Error>;
pub struct Directories {
inner: platform::Directories,
}
impl Directories {
pub fn with_prefix<P, Q>(prefix_lowercased: P, prefix_capitalized: Q)
-> Result<Directories>
where P: AsRef<Path>, Q: AsRef<Path>
{
fn with_prefix_(prefix_lowercased: &Path, prefix_capitalized: &Path)
-> Result<Directories>
{
Ok(Directories {
inner: try!(platform::Directories::with_prefix(prefix_lowercased,
prefix_capitalized)),
})
}
with_prefix_(prefix_lowercased.as_ref(), prefix_capitalized.as_ref())
}
pub fn config_home(&self) -> PathBuf {
self.inner.config_home()
}
pub fn cache_home(&self) -> PathBuf {
self.inner.cache_home()
}
pub fn bin_home(&self) -> PathBuf {
self.inner.bin_home()
}
}