diff --git a/ergo/src/deep_copy.rs b/ergo/src/deep_copy.rs index 7e8146d..a9d1d84 100644 --- a/ergo/src/deep_copy.rs +++ b/ergo/src/deep_copy.rs @@ -94,7 +94,8 @@ fn walk_and_create_dirs( } fn create_dir_maybe>(path: P) -> path_abs::Result { - let arc = PathArc::new(path); - fs::create_dir(&arc).map_err(|err| path_abs::Error::new(err, "creating dir", arc.clone()))?; - PathDir::new(arc) + let path = path.as_ref(); + fs::create_dir(path) + .map_err(|err| path_abs::Error::new(err, "creating dir", PathBuf::from(path).into()))?; + PathDir::new(path) } diff --git a/ergo_fs/Cargo.toml b/ergo_fs/Cargo.toml index 3b1ef22..c7e3f81 100644 --- a/ergo_fs/Cargo.toml +++ b/ergo_fs/Cargo.toml @@ -17,7 +17,7 @@ version = "0.2.0" [dependencies] glob = "0.2.11" -path_abs = "^0.4.0" +path_abs = {git="https://github.com/vitiral/path_abs"} shellexpand = "1.0.0" std_prelude = "^0.2.9" tar = "^0.4.14" diff --git a/ergo_fs/src/lib.rs b/ergo_fs/src/lib.rs index c5d0c4c..8336a57 100644 --- a/ergo_fs/src/lib.rs +++ b/ergo_fs/src/lib.rs @@ -163,7 +163,7 @@ pub extern crate walkdir; use std::borrow::Cow; // FIXME: remove this use std_prelude::*; -pub use path_abs::{FileEdit, FileRead, FileWrite, PathAbs, PathArc, PathDir, PathFile, PathType}; +pub use path_abs::{FileEdit, FileRead, FileWrite, PathAbs, PathDir, PathFile, PathType, PathInfo, PathOps, PathMut, PathSer}; pub use walkdir::{Error as WalkError, WalkDir}; pub use std_prelude::{Read, IoWrite, Path, PathBuf}; @@ -221,12 +221,12 @@ pub trait PathTypeExt { let abs = PathAbs::new(entry.path())?; let ty = entry.file_type(); if ty.is_file() { - Ok(PathType::File(PathFile::from_abs_unchecked(abs))) + Ok(PathType::File(PathFile::new_unchecked(abs))) } else if ty.is_dir() { - Ok(PathType::Dir(PathDir::from_abs_unchecked(abs))) + Ok(PathType::Dir(PathDir::new_unchecked(abs))) } else { // it is a symlink and we _must_ use a syscall to resolve the type. - PathType::from_abs(abs) + PathType::try_from(abs) } } } diff --git a/ergo_fs/src/tmp.rs b/ergo_fs/src/tmp.rs index 09c81e1..ebc719e 100644 --- a/ergo_fs/src/tmp.rs +++ b/ergo_fs/src/tmp.rs @@ -16,7 +16,7 @@ use std::fmt; use std_prelude::*; use tempdir; -use path_abs::{Error, PathAbs, PathArc, PathDir, Result}; +use path_abs::{Error, PathAbs, PathDir, Result}; /// A `PathDir` that is automatically deleted when it goes out of scope. /// @@ -75,7 +75,7 @@ impl PathTmp { /// /// # Examples /// ``` - /// use ergo_fs::{PathFile, PathTmp}; + /// use ergo_fs::{PathFile, PathTmp, PathInfo, PathOps}; /// /// let tmp_dir = PathTmp::create("example").unwrap(); /// let file = PathFile::create(tmp_dir.join("temporary-note.txt")).unwrap(); @@ -103,7 +103,7 @@ impl PathTmp { /// # Examples /// /// ``` - /// use ergo_fs::{PathFile, PathTmp}; + /// use ergo_fs::{PathFile, PathTmp, PathInfo, PathOps}; /// /// let tmp_dir = PathTmp::create_in(".", "example").unwrap(); /// let file = PathFile::create(tmp_dir.join("temporary-note.txt")).unwrap(); @@ -118,7 +118,7 @@ impl PathTmp { /// ``` pub fn create_in>(base: P, prefix: &str) -> Result { let tmp = tempdir::TempDir::new_in(&base, prefix) - .map_err(|err| Error::new(err, "creating tmpdir", PathArc::new(&base)))?; + .map_err(|err| Error::new(err, "creating tmpdir", PathBuf::from(base.as_ref()).into()))?; Ok(PathTmp { dir: PathDir::new(tmp.path())?, @@ -134,7 +134,7 @@ impl PathTmp { /// # Examples /// /// ``` - /// use ergo_fs::PathTmp; + /// use ergo_fs::{PathTmp, PathInfo}; /// /// let tmp_dir = PathTmp::create_in(".", "persist").unwrap(); /// let dir = tmp_dir.persist(); @@ -217,7 +217,7 @@ impl Deref for PathTmp { type Target = PathAbs; fn deref(&self) -> &PathAbs { - &self.dir + self.dir.as_ref() } } @@ -228,13 +228,6 @@ impl Into for PathTmp { } } -impl Into for PathTmp { - /// Downgrades the `PathTmp` into a `PathArc` - fn into(self) -> PathArc { - self.dir.into() - } -} - impl Into for PathTmp { /// Downgrades the `PathTmp` into a `PathBuf`. Avoids a clone if this is the only reference. fn into(self) -> PathBuf { diff --git a/ergo_std/Cargo.toml b/ergo_std/Cargo.toml index 40fa3e3..3fef18b 100644 --- a/ergo_std/Cargo.toml +++ b/ergo_std/Cargo.toml @@ -20,4 +20,4 @@ regex = "0.2.5" serde = "1.0" serde_derive = "1.0" std_prelude = "0.2" -indexmap = "1.0.1" +indexmap = {version="1.0.1", features=["serde-1"]}