Handbook
Glossary
list-directory ( server path -- )
Vocabulary
gemini
.
server
.
private
Inputs
server
an
object
path
an
object
Outputs
None
Definition
USING:
accessors
combinators.short-circuit
formatting
io.directories
io.files.info
io.pathnames
kernel
sequences
sorting
splitting
urls.encoding
;
IN:
gemini.server.private
::
list-directory
( server path -- )
path server
serving-directory>>
?head
drop
[
"# [%s]\r\n\r\n"
sprintf
write-utf8
]
[
dup
"/"
=
[
drop
]
[
parent-directory
".."
"=> %s %-69s\r\n"
sprintf
write-utf8
]
if
]
bi
path
[
[
name>>
"."
head?
]
reject
[
{
[
directory?
]
[
regular-file?
]
}
1||
]
filter
[
name>>
]
sort-by
[
[
name>>
]
[
directory?
[
"/"
append
]
when
]
bi
[
url-encode
]
[
dup
file-info
[
file-modified
]
[
file-size
]
bi
"%-40s %s %10s"
sprintf
]
bi
"=> %s %s\r\n"
sprintf
write-utf8
]
each
]
with-directory-entries
;