summaryrefslogtreecommitdiffstats
path: root/vendor/fs-err/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/fs-err/src/lib.rs')
-rw-r--r--vendor/fs-err/src/lib.rs43
1 files changed, 22 insertions, 21 deletions
diff --git a/vendor/fs-err/src/lib.rs b/vendor/fs-err/src/lib.rs
index 3cc8a3b4d..777db9535 100644
--- a/vendor/fs-err/src/lib.rs
+++ b/vendor/fs-err/src/lib.rs
@@ -1,7 +1,7 @@
/*!
fs-err is a drop-in replacement for [`std::fs`][std::fs] that provides more
helpful messages on errors. Extra information includes which operations was
-attmpted and any involved paths.
+attempted and any involved paths.
# Error Messages
@@ -66,8 +66,9 @@ println!("Program config: {:?}", decoded);
[serde_json]: https://crates.io/crates/serde_json
*/
-#![doc(html_root_url = "https://docs.rs/fs-err/2.5.0")]
+#![doc(html_root_url = "https://docs.rs/fs-err/2.8.1")]
#![deny(missing_debug_implementations, missing_docs)]
+#![cfg_attr(docsrs, feature(doc_cfg))]
mod dir;
mod errors;
@@ -90,20 +91,20 @@ pub use path::PathExt;
/// Wrapper for [`fs::read`](https://doc.rust-lang.org/stable/std/fs/fn.read.html).
pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
let path = path.as_ref();
- let mut file = file::open(path.as_ref()).map_err(|err_gen| err_gen(path.to_path_buf()))?;
+ let mut file = file::open(path).map_err(|err_gen| err_gen(path.to_path_buf()))?;
let mut bytes = Vec::with_capacity(initial_buffer_size(&file));
file.read_to_end(&mut bytes)
- .map_err(|err| Error::new(err, ErrorKind::Read, path))?;
+ .map_err(|err| Error::build(err, ErrorKind::Read, path))?;
Ok(bytes)
}
/// Wrapper for [`fs::read_to_string`](https://doc.rust-lang.org/stable/std/fs/fn.read_to_string.html).
pub fn read_to_string<P: AsRef<Path>>(path: P) -> io::Result<String> {
let path = path.as_ref();
- let mut file = file::open(path.as_ref()).map_err(|err_gen| err_gen(path.to_path_buf()))?;
+ let mut file = file::open(path).map_err(|err_gen| err_gen(path.to_path_buf()))?;
let mut string = String::with_capacity(initial_buffer_size(&file));
file.read_to_string(&mut string)
- .map_err(|err| Error::new(err, ErrorKind::Read, path))?;
+ .map_err(|err| Error::build(err, ErrorKind::Read, path))?;
Ok(string)
}
@@ -113,7 +114,7 @@ pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> io::Result
file::create(path)
.map_err(|err_gen| err_gen(path.to_path_buf()))?
.write_all(contents.as_ref())
- .map_err(|err| Error::new(err, ErrorKind::Write, path))
+ .map_err(|err| Error::build(err, ErrorKind::Write, path))
}
/// Wrapper for [`fs::copy`](https://doc.rust-lang.org/stable/std/fs/fn.copy.html).
@@ -125,7 +126,7 @@ where
let from = from.as_ref();
let to = to.as_ref();
fs::copy(from, to)
- .map_err(|source| SourceDestError::new(source, SourceDestErrorKind::Copy, from, to))
+ .map_err(|source| SourceDestError::build(source, SourceDestErrorKind::Copy, from, to))
}
/// Wrapper for [`fs::create_dir`](https://doc.rust-lang.org/stable/std/fs/fn.create_dir.html).
@@ -134,7 +135,7 @@ where
P: AsRef<Path>,
{
let path = path.as_ref();
- fs::create_dir(path).map_err(|source| Error::new(source, ErrorKind::CreateDir, path))
+ fs::create_dir(path).map_err(|source| Error::build(source, ErrorKind::CreateDir, path))
}
/// Wrapper for [`fs::create_dir_all`](https://doc.rust-lang.org/stable/std/fs/fn.create_dir_all.html).
@@ -143,7 +144,7 @@ where
P: AsRef<Path>,
{
let path = path.as_ref();
- fs::create_dir_all(path).map_err(|source| Error::new(source, ErrorKind::CreateDir, path))
+ fs::create_dir_all(path).map_err(|source| Error::build(source, ErrorKind::CreateDir, path))
}
/// Wrapper for [`fs::remove_dir`](https://doc.rust-lang.org/stable/std/fs/fn.remove_dir.html).
@@ -152,7 +153,7 @@ where
P: AsRef<Path>,
{
let path = path.as_ref();
- fs::remove_dir(path).map_err(|source| Error::new(source, ErrorKind::RemoveDir, path))
+ fs::remove_dir(path).map_err(|source| Error::build(source, ErrorKind::RemoveDir, path))
}
/// Wrapper for [`fs::remove_dir_all`](https://doc.rust-lang.org/stable/std/fs/fn.remove_dir_all.html).
@@ -161,7 +162,7 @@ where
P: AsRef<Path>,
{
let path = path.as_ref();
- fs::remove_dir_all(path).map_err(|source| Error::new(source, ErrorKind::RemoveDir, path))
+ fs::remove_dir_all(path).map_err(|source| Error::build(source, ErrorKind::RemoveDir, path))
}
/// Wrapper for [`fs::remove_file`](https://doc.rust-lang.org/stable/std/fs/fn.remove_file.html).
@@ -170,19 +171,19 @@ where
P: AsRef<Path>,
{
let path = path.as_ref();
- fs::remove_file(path).map_err(|source| Error::new(source, ErrorKind::RemoveFile, path))
+ fs::remove_file(path).map_err(|source| Error::build(source, ErrorKind::RemoveFile, path))
}
/// Wrapper for [`fs::metadata`](https://doc.rust-lang.org/stable/std/fs/fn.metadata.html).
pub fn metadata<P: AsRef<Path>>(path: P) -> io::Result<fs::Metadata> {
let path = path.as_ref();
- fs::metadata(path).map_err(|source| Error::new(source, ErrorKind::Metadata, path))
+ fs::metadata(path).map_err(|source| Error::build(source, ErrorKind::Metadata, path))
}
/// Wrapper for [`fs::canonicalize`](https://doc.rust-lang.org/stable/std/fs/fn.canonicalize.html).
pub fn canonicalize<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
let path = path.as_ref();
- fs::canonicalize(path).map_err(|source| Error::new(source, ErrorKind::Canonicalize, path))
+ fs::canonicalize(path).map_err(|source| Error::build(source, ErrorKind::Canonicalize, path))
}
/// Wrapper for [`fs::hard_link`](https://doc.rust-lang.org/stable/std/fs/fn.hard_link.html).
@@ -190,13 +191,13 @@ pub fn hard_link<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<(
let src = src.as_ref();
let dst = dst.as_ref();
fs::hard_link(src, dst)
- .map_err(|source| SourceDestError::new(source, SourceDestErrorKind::HardLink, src, dst))
+ .map_err(|source| SourceDestError::build(source, SourceDestErrorKind::HardLink, src, dst))
}
/// Wrapper for [`fs::read_link`](https://doc.rust-lang.org/stable/std/fs/fn.read_link.html).
pub fn read_link<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
let path = path.as_ref();
- fs::read_link(path).map_err(|source| Error::new(source, ErrorKind::ReadLink, path))
+ fs::read_link(path).map_err(|source| Error::build(source, ErrorKind::ReadLink, path))
}
/// Wrapper for [`fs::rename`](https://doc.rust-lang.org/stable/std/fs/fn.rename.html).
@@ -204,7 +205,7 @@ pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()>
let from = from.as_ref();
let to = to.as_ref();
fs::rename(from, to)
- .map_err(|source| SourceDestError::new(source, SourceDestErrorKind::Rename, from, to))
+ .map_err(|source| SourceDestError::build(source, SourceDestErrorKind::Rename, from, to))
}
/// Wrapper for [`fs::soft_link`](https://doc.rust-lang.org/stable/std/fs/fn.soft_link.html).
@@ -215,21 +216,21 @@ pub fn soft_link<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<(
let dst = dst.as_ref();
#[allow(deprecated)]
fs::soft_link(src, dst)
- .map_err(|source| SourceDestError::new(source, SourceDestErrorKind::SoftLink, src, dst))
+ .map_err(|source| SourceDestError::build(source, SourceDestErrorKind::SoftLink, src, dst))
}
/// Wrapper for [`fs::symlink_metadata`](https://doc.rust-lang.org/stable/std/fs/fn.symlink_metadata.html).
pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<fs::Metadata> {
let path = path.as_ref();
fs::symlink_metadata(path)
- .map_err(|source| Error::new(source, ErrorKind::SymlinkMetadata, path))
+ .map_err(|source| Error::build(source, ErrorKind::SymlinkMetadata, path))
}
/// Wrapper for [`fs::set_permissions`](https://doc.rust-lang.org/stable/std/fs/fn.set_permissions.html).
pub fn set_permissions<P: AsRef<Path>>(path: P, perm: fs::Permissions) -> io::Result<()> {
let path = path.as_ref();
fs::set_permissions(path, perm)
- .map_err(|source| Error::new(source, ErrorKind::SetPermissions, path))
+ .map_err(|source| Error::build(source, ErrorKind::SetPermissions, path))
}
fn initial_buffer_size(file: &std::fs::File) -> usize {