-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: try to support iouring * chore: make cargo docs work * feat: all in epoll * chore: apply review * chore: fix tokio macros * chore: fix features
- Loading branch information
Chojan Shang
authored
Jul 29, 2022
1 parent
fd3ef54
commit b609cde
Showing
6 changed files
with
110 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,3 +92,4 @@ pub use backend::Builder; | |
|
||
mod dir_stream; | ||
mod error; | ||
mod nfs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// Copyright 2022 Datafuse Labs. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//! Async filesystem primitives. | ||
//! We use [`nuclei`] to support io-uring. | ||
//! | ||
//! [`nuclei`]: https://docs.rs/nuclei | ||
#![warn(missing_docs)] | ||
use std::io; | ||
use std::path::Path; | ||
|
||
use nuclei::spawn_blocking; | ||
|
||
#[doc(no_inline)] | ||
pub use std::fs::{FileType, Metadata, Permissions}; | ||
|
||
/// Creates a directory and its parent directories if they are missing. | ||
/// | ||
/// # Errors | ||
/// | ||
/// An error will be returned in the following situations: | ||
/// | ||
/// * `path` already points to an existing file or directory. | ||
/// * The current process lacks permissions to create the directory or its missing parents. | ||
/// * Some other I/O error occurred. | ||
pub async fn create_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> { | ||
let path = path.as_ref().to_owned(); | ||
spawn_blocking(move || std::fs::create_dir_all(&path)).await | ||
} | ||
|
||
/// Reads metadata for a path. | ||
/// | ||
/// This function will traverse symbolic links to read metadata for the target file or directory. | ||
/// If you want to read metadata without following symbolic links, use [`symlink_metadata()`] | ||
/// instead. | ||
/// | ||
/// # Errors | ||
/// | ||
/// An error will be returned in the following situations: | ||
/// | ||
/// * `path` does not point to an existing file or directory. | ||
/// * The current process lacks permissions to read metadata for the path. | ||
/// * Some other I/O error occurred. | ||
pub async fn metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> { | ||
let path = path.as_ref().to_owned(); | ||
spawn_blocking(move || std::fs::metadata(path)).await | ||
} | ||
|
||
/// Removes an empty directory. | ||
/// | ||
/// Note that this function can only delete an empty directory. If you want to delete a directory | ||
/// and all of its contents, use [`remove_dir_all()`] instead. | ||
/// | ||
/// # Errors | ||
/// | ||
/// An error will be returned in the following situations: | ||
/// | ||
/// * `path` is not an existing and empty directory. | ||
/// * The current process lacks permissions to remove the directory. | ||
/// * Some other I/O error occurred. | ||
pub async fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> { | ||
let path = path.as_ref().to_owned(); | ||
spawn_blocking(move || std::fs::remove_dir(&path)).await | ||
} | ||
|
||
/// Removes a file. | ||
/// | ||
/// # Errors | ||
/// | ||
/// An error will be returned in the following situations: | ||
/// | ||
/// * `path` does not point to an existing file. | ||
/// * The current process lacks permissions to remove the file. | ||
/// * Some other I/O error occurred. | ||
pub async fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> { | ||
let path = path.as_ref().to_owned(); | ||
spawn_blocking(move || std::fs::remove_file(&path)).await | ||
} |
b609cde
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for opendal ready!
✅ Preview
https://opendal-lt8u22wim-databend.vercel.app
Built with commit b609cde.
This pull request is being automatically deployed with vercel-action