mirror of
https://github.com/YGGverse/agate.git
synced 2026-04-09 13:05:29 +00:00
Use async version of read_dir
This commit is contained in:
parent
0909a4def8
commit
a70f5e6100
1 changed files with 3 additions and 2 deletions
|
|
@ -228,13 +228,14 @@ async fn send_header<W: Write + Unpin>(stream: &mut W, status: &str, meta: &[&st
|
||||||
async fn list_directory<W: Write + Unpin>(stream: &mut W, path: &Path) -> Result {
|
async fn list_directory<W: Write + Unpin>(stream: &mut W, path: &Path) -> Result {
|
||||||
log::info!("Listing directory {:?}", path);
|
log::info!("Listing directory {:?}", path);
|
||||||
send_text_gemini_header(stream).await?;
|
send_text_gemini_header(stream).await?;
|
||||||
for entry in std::fs::read_dir(path)? {
|
let mut entries = async_std::fs::read_dir(path).await?;
|
||||||
|
while let Some(entry) = entries.next().await {
|
||||||
let entry = entry?;
|
let entry = entry?;
|
||||||
let mut name = entry.file_name().into_string().or(Err("Non-Unicode filename"))?;
|
let mut name = entry.file_name().into_string().or(Err("Non-Unicode filename"))?;
|
||||||
if name.starts_with('.') {
|
if name.starts_with('.') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if entry.file_type()?.is_dir() {
|
if entry.file_type().await?.is_dir() {
|
||||||
name += "/";
|
name += "/";
|
||||||
}
|
}
|
||||||
stream.write_all(b"=> ").await?;
|
stream.write_all(b"=> ").await?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue