bytecodealliance / bytecodealliance/cap-std

Create directory if not exists, and return `Dir`

Đang mở
#372 7 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Rust
Star
821
Fork
57
Merge trung bình
1 giờ 16 phút
Pull request đã merge (30 ngày)
4

Mô tả

Is there a simple way to create a directory if it does not yet exist and to return the `Dir`?

Something along the lines of:

```rs
async fn create_dir(parent: &Dir, path: &str) -> anyhow::Result {
match parent.create_dir(path) {
Ok(_) => {}
Err(e) => match e.kind() {
std::io::ErrorKind::AlreadyExists => {}
_ => {
Err(e)?;
}
},
}
Ok(parent.open_dir(path).await?) // could maybe be a TOCTOU?
}
```

I couldn't find a `create_dir_with` that would allow specifying e.g. `OpenOptions`, and all the create_dir functions don't return the `Dir` itself.

If not, would the project be open to contributions on this?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Start by reviewing the existing `Dir::create_dir`, `Dir::open_dir`, and related create-directory APIs. Check how the project handles `OpenOptions`, existing directories, and possible TOCTOU concerns. Done should be a reviewed API that creates or opens the directory, supports the requested options, and returns `Dir` with appropriate tests.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
rust
Lĩnh vực
operating-systems, security
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.