Skip to content

Commit e7e02fc

Browse files
authored
fs: use FileOptions inside fs::File to support uring (#7617)
1 parent f7a7f62 commit e7e02fc

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tokio/src/fs/file.rs

Lines changed: 7 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,12 @@ 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()
189+
.write(true)
190+
.create(true)
191+
.truncate(true)
192+
.open(path)
193+
.await
194194
}
195195

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

0 commit comments

Comments
 (0)