Skip to content

Commit 00a8433

Browse files
authored
Merge pull request #320 from Wassasin/183-async-path
Implement async Path & PathBuf
2 parents 612a94b + aa13ba7 commit 00a8433

31 files changed

+1127
-53
lines changed

src/fs/canonicalize.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use std::path::{Path, PathBuf};
2-
31
use crate::io;
2+
use crate::path::{Path, PathBuf};
43
use crate::task::blocking;
54

65
/// Returns the canonical form of a path.
@@ -33,5 +32,5 @@ use crate::task::blocking;
3332
/// ```
3433
pub async fn canonicalize<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
3534
let path = path.as_ref().to_owned();
36-
blocking::spawn(async move { std::fs::canonicalize(path) }).await
35+
blocking::spawn(async move { std::fs::canonicalize(&path).map(Into::into) }).await
3736
}

src/fs/copy.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use std::path::Path;
2-
31
use crate::io;
2+
use crate::path::Path;
43
use crate::task::blocking;
54

65
/// Copies the contents and permissions of a file to a new location.

src/fs/create_dir.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use std::path::Path;
2-
31
use crate::io;
2+
use crate::path::Path;
43
use crate::task::blocking;
54

65
/// Creates a new directory.

src/fs/create_dir_all.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use std::path::Path;
2-
31
use crate::io;
2+
use crate::path::Path;
43
use crate::task::blocking;
54

65
/// Creates a new directory and all of its parents if they are missing.

src/fs/dir_builder.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
use std::path::Path;
2-
31
use cfg_if::cfg_if;
42

53
use crate::future::Future;
64
use crate::io;
5+
use crate::path::Path;
76
use crate::task::blocking;
87

98
/// A builder for creating directories with configurable options.

src/fs/dir_entry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use std::ffi::OsString;
22
use std::fmt;
3-
use std::path::PathBuf;
43
use std::sync::Arc;
54

65
use cfg_if::cfg_if;
76

87
use crate::fs::{FileType, Metadata};
98
use crate::io;
9+
use crate::path::PathBuf;
1010
use crate::task::blocking;
1111

1212
/// An entry in a directory.
@@ -50,7 +50,7 @@ impl DirEntry {
5050
/// # Ok(()) }) }
5151
/// ```
5252
pub fn path(&self) -> PathBuf {
53-
self.0.path()
53+
self.0.path().into()
5454
}
5555

5656
/// Reads the metadata for this entry.

src/fs/file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::cmp;
33
use std::fmt;
44
use std::io::{Read as _, Seek as _, Write as _};
55
use std::ops::{Deref, DerefMut};
6-
use std::path::Path;
76
use std::pin::Pin;
87
use std::sync::atomic::{AtomicBool, Ordering};
98
use std::sync::{Arc, Mutex};
@@ -13,6 +12,7 @@ use cfg_if::cfg_if;
1312
use crate::fs::{Metadata, Permissions};
1413
use crate::future;
1514
use crate::io::{self, Read, Seek, SeekFrom, Write};
15+
use crate::path::Path;
1616
use crate::prelude::*;
1717
use crate::task::{self, blocking, Context, Poll, Waker};
1818

src/fs/hard_link.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use std::path::Path;
2-
31
use crate::io;
2+
use crate::path::Path;
43
use crate::task::blocking;
54

65
/// Creates a hard link on the filesystem.

src/fs/metadata.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
use std::path::Path;
2-
31
use cfg_if::cfg_if;
42

53
use crate::io;
4+
use crate::path::Path;
65
use crate::task::blocking;
76

87
/// Reads metadata for a path.

src/fs/open_options.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
use std::path::Path;
2-
31
use cfg_if::cfg_if;
42

53
use crate::fs::File;
64
use crate::future::Future;
75
use crate::io;
6+
use crate::path::Path;
87
use crate::task::blocking;
98

109
/// A builder for opening files with configurable options.

0 commit comments

Comments
 (0)