diff options
author | Carl Lerche <me@carllerche.com> | 2019-10-21 15:49:00 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-21 15:49:00 -0700 |
commit | 978013a215ebae63cd087139514de32bbd36ce11 (patch) | |
tree | dcf43cf2ac044ec9031a79901aa6956351c27ee4 /tokio/src/fs/set_permissions.rs | |
parent | 6aa6ebb5bce7b2b8c5b81814b6ea47994f0f54d9 (diff) |
fs: move into `tokio` (#1672)
A step towards collapsing Tokio sub crates into a single `tokio`
crate (#1318).
The `fs` implementation is now provided by the main `tokio` crate. The
`fs` functionality may still be excluded from the build by skipping the
`fs` feature flag.
Diffstat (limited to 'tokio/src/fs/set_permissions.rs')
-rw-r--r-- | tokio/src/fs/set_permissions.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tokio/src/fs/set_permissions.rs b/tokio/src/fs/set_permissions.rs new file mode 100644 index 00000000..6e640544 --- /dev/null +++ b/tokio/src/fs/set_permissions.rs @@ -0,0 +1,15 @@ +use crate::fs::asyncify; + +use std::fs::Permissions; +use std::io; +use std::path::Path; + +/// Changes the permissions found on a file or a directory. +/// +/// This is an async version of [`std::fs::set_permissions`][std] +/// +/// [std]: https://doc.rust-lang.org/std/fs/fn.set_permissions.html +pub async fn set_permissions<P: AsRef<Path>>(path: P, perm: Permissions) -> io::Result<()> { + let path = path.as_ref().to_owned(); + asyncify(|| std::fs::set_permissions(path, perm)).await +} |