Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to path_abs-4.0 #12

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions ergo/src/deep_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ fn walk_and_create_dirs(
}

fn create_dir_maybe<P: AsRef<Path>>(path: P) -> path_abs::Result<PathDir> {
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)
}
2 changes: 1 addition & 1 deletion ergo_fs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions ergo_fs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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)
}
}
}
Expand Down
19 changes: 6 additions & 13 deletions ergo_fs/src/tmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -118,7 +118,7 @@ impl PathTmp {
/// ```
pub fn create_in<P: AsRef<Path>>(base: P, prefix: &str) -> Result<PathTmp> {
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())?,
Expand All @@ -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();
Expand Down Expand Up @@ -217,7 +217,7 @@ impl Deref for PathTmp {
type Target = PathAbs;

fn deref(&self) -> &PathAbs {
&self.dir
self.dir.as_ref()
}
}

Expand All @@ -228,13 +228,6 @@ impl Into<PathAbs> for PathTmp {
}
}

impl Into<PathArc> for PathTmp {
/// Downgrades the `PathTmp` into a `PathArc`
fn into(self) -> PathArc {
self.dir.into()
}
}

impl Into<PathBuf> for PathTmp {
/// Downgrades the `PathTmp` into a `PathBuf`. Avoids a clone if this is the only reference.
fn into(self) -> PathBuf {
Expand Down
2 changes: 1 addition & 1 deletion ergo_std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}