Lines Matching +full:build +full:- +full:std
2 fs-err is a drop-in replacement for [`std::fs`][std::fs] that provides more
8 Using [`std::fs`][std::fs], if this code fails:
11 # use std::fs::File;
13 # Ok::<(), std::io::Error>(())
22 ...but if we use fs-err instead, our error contains more actionable information:
31 fs-err's API is the same as [`std::fs`][std::fs], so migrating code to use it is easy.
34 // use std::fs;
41 # Ok::<(), std::io::Error>(())
44 fs-err uses [`std::io::Error`][std::io::Error] for all errors. This helps fs-err
46 [`std::io::Read`][std::io::Read] and crates that use them like
52 let file = File::open("my-config.json")?;
60 # Ok::<(), Box<dyn std::error::Error>>(())
63 [std::fs]: https://doc.rust-lang.org/stable/std/fs/
64 [std::io::Error]: https://doc.rust-lang.org/stable/std/io/struct.Error.html
65 [std::io::Read]: https://doc.rust-lang.org/stable/std/io/trait.Read.html
69 #![doc(html_root_url = "https://docs.rs/fs-err/2.11.0")]
83 use std::fs;
84 use std::io::{self, Read, Write};
85 use std::path::{Path, PathBuf};
96 /// Wrapper for [`fs::read`](https://doc.rust-lang.org/stable/std/fs/fn.read.html).
97 pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> { in read()
102 .map_err(|err| Error::build(err, ErrorKind::Read, path))?; in read()
108 /// Wrapper for [`fs::read_to_string`](https://doc.rust-lang.org/stable/std/fs/fn.read_to_string.ht…
109 pub fn read_to_string<P: AsRef<Path>>(path: P) -> io::Result<String> { in read_to_string()
114 .map_err(|err| Error::build(err, ErrorKind::Read, path))?; in read_to_string()
120 /// Wrapper for [`fs::write`](https://doc.rust-lang.org/stable/std/fs/fn.write.html).
121 pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> io::Result<()> { in write()
126 .map_err(|err| Error::build(err, ErrorKind::Write, path)) in write()
132 /// Wrapper for [`fs::copy`](https://doc.rust-lang.org/stable/std/fs/fn.copy.html).
133 pub fn copy<P, Q>(from: P, to: Q) -> io::Result<u64> in copy()
141 .map_err(|source| SourceDestError::build(source, SourceDestErrorKind::Copy, from, to)) in copy()
146 /// Wrapper for [`fs::create_dir`](https://doc.rust-lang.org/stable/std/fs/fn.create_dir.html).
147 pub fn create_dir<P>(path: P) -> io::Result<()> in create_dir()
152 fs::create_dir(path).map_err(|source| Error::build(source, ErrorKind::CreateDir, path)) in create_dir()
157 /// Wrapper for [`fs::create_dir_all`](https://doc.rust-lang.org/stable/std/fs/fn.create_dir_all.ht…
158 pub fn create_dir_all<P>(path: P) -> io::Result<()> in create_dir_all()
163 fs::create_dir_all(path).map_err(|source| Error::build(source, ErrorKind::CreateDir, path)) in create_dir_all()
168 /// Wrapper for [`fs::remove_dir`](https://doc.rust-lang.org/stable/std/fs/fn.remove_dir.html).
169 pub fn remove_dir<P>(path: P) -> io::Result<()> in remove_dir()
174 fs::remove_dir(path).map_err(|source| Error::build(source, ErrorKind::RemoveDir, path)) in remove_dir()
179 /// Wrapper for [`fs::remove_dir_all`](https://doc.rust-lang.org/stable/std/fs/fn.remove_dir_all.ht…
180 pub fn remove_dir_all<P>(path: P) -> io::Result<()> in remove_dir_all()
185 fs::remove_dir_all(path).map_err(|source| Error::build(source, ErrorKind::RemoveDir, path)) in remove_dir_all()
190 /// Wrapper for [`fs::remove_file`](https://doc.rust-lang.org/stable/std/fs/fn.remove_file.html).
191 pub fn remove_file<P>(path: P) -> io::Result<()> in remove_file()
196 fs::remove_file(path).map_err(|source| Error::build(source, ErrorKind::RemoveFile, path)) in remove_file()
201 /// Wrapper for [`fs::metadata`](https://doc.rust-lang.org/stable/std/fs/fn.metadata.html).
202 pub fn metadata<P: AsRef<Path>>(path: P) -> io::Result<fs::Metadata> { in metadata()
204 fs::metadata(path).map_err(|source| Error::build(source, ErrorKind::Metadata, path)) in metadata()
210 /// Wrapper for [`fs::canonicalize`](https://doc.rust-lang.org/stable/std/fs/fn.canonicalize.html).
211 pub fn canonicalize<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> { in canonicalize()
213 fs::canonicalize(path).map_err(|source| Error::build(source, ErrorKind::Canonicalize, path)) in canonicalize()
218 /// Wrapper for [`fs::hard_link`](https://doc.rust-lang.org/stable/std/fs/fn.hard_link.html).
219 pub fn hard_link<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> { in hard_link()
223 .map_err(|source| SourceDestError::build(source, SourceDestErrorKind::HardLink, src, dst)) in hard_link()
228 /// Wrapper for [`fs::read_link`](https://doc.rust-lang.org/stable/std/fs/fn.read_link.html).
229 pub fn read_link<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> { in read_link()
231 fs::read_link(path).map_err(|source| Error::build(source, ErrorKind::ReadLink, path)) in read_link()
236 /// Wrapper for [`fs::rename`](https://doc.rust-lang.org/stable/std/fs/fn.rename.html).
237 pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()> { in rename()
241 .map_err(|source| SourceDestError::build(source, SourceDestErrorKind::Rename, from, to)) in rename()
244 /// Wrapper for [`fs::soft_link`](https://doc.rust-lang.org/stable/std/fs/fn.soft_link.html).
245 #[deprecated = "replaced with std::os::unix::fs::symlink and \
246 std::os::windows::fs::{symlink_file, symlink_dir}"]
247 pub fn soft_link<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> { in soft_link()
252 .map_err(|source| SourceDestError::build(source, SourceDestErrorKind::SoftLink, src, dst)) in soft_link()
257 /// Wrapper for [`fs::symlink_metadata`](https://doc.rust-lang.org/stable/std/fs/fn.symlink_metadat…
258 pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<fs::Metadata> { in symlink_metadata()
261 .map_err(|source| Error::build(source, ErrorKind::SymlinkMetadata, path)) in symlink_metadata()
266 /// Wrapper for [`fs::set_permissions`](https://doc.rust-lang.org/stable/std/fs/fn.set_permissions.…
267 pub fn set_permissions<P: AsRef<Path>>(path: P, perm: fs::Permissions) -> io::Result<()> { in set_permissions()
270 .map_err(|source| Error::build(source, ErrorKind::SetPermissions, path)) in set_permissions()
273 fn initial_buffer_size(file: &std::fs::File) -> usize { in initial_buffer_size()
282 impl Sealed for std::path::Path {}