Skip to content

Commit f111527

Browse files
author
Denis Davydov
committed
fs: use FileOptions inside fs::File to support uring
1 parent 637fc1d commit f111527

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

tokio/src/fs/file.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,7 @@ impl File {
150150
/// [`read_to_end`]: fn@crate::io::AsyncReadExt::read_to_end
151151
/// [`AsyncReadExt`]: trait@crate::io::AsyncReadExt
152152
pub async fn open(path: impl AsRef<Path>) -> io::Result<File> {
153-
let path = path.as_ref().to_owned();
154-
let std = asyncify(|| StdFile::open(path)).await?;
155-
156-
Ok(File::from_std(std))
153+
Self::options().read(true).open(path).await
157154
}
158155

159156
/// Opens a file in write-only mode.
@@ -188,9 +185,7 @@ impl File {
188185
/// [`write_all`]: fn@crate::io::AsyncWriteExt::write_all
189186
/// [`AsyncWriteExt`]: trait@crate::io::AsyncWriteExt
190187
pub async fn create(path: impl AsRef<Path>) -> io::Result<File> {
191-
let path = path.as_ref().to_owned();
192-
let std_file = asyncify(move || StdFile::create(path)).await?;
193-
Ok(File::from_std(std_file))
188+
Self::options().write(true).create(true).truncate(true).open(path).await
194189
}
195190

196191
/// Opens a file in read-write mode.

0 commit comments

Comments
 (0)