mirror of
https://github.com/samsonjs/agate.git
synced 2026-03-25 09:05:50 +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 {
|
||||
log::info!("Listing directory {:?}", path);
|
||||
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 mut name = entry.file_name().into_string().or(Err("Non-Unicode filename"))?;
|
||||
if name.starts_with('.') {
|
||||
continue;
|
||||
}
|
||||
if entry.file_type()?.is_dir() {
|
||||
if entry.file_type().await?.is_dir() {
|
||||
name += "/";
|
||||
}
|
||||
stream.write_all(b"=> ").await?;
|
||||
|
|
|
|||
Loading…
Reference in a new issue