Handbook
Glossary
list-directory ( server path -- )
Vocabulary
gopher
.
server
.
private
Inputs
server
an
object
path
an
object
Outputs
None
Definition
USING:
accessors
combinators.short-circuit
formatting
io
io.directories
io.encodings.string
io.encodings.utf8
io.files.info
io.pathnames
kernel
sequences
sorting
splitting
urls.encoding
;
IN:
gopher.server.private
::
list-directory
( server path -- )
path server
serving-directory>>
?head
drop
[
[
"/"
]
when-empty
"i[%s]\t\terror.host\t1\r\n\r\n"
sprintf
utf8
encode
write
]
[
[
".."
swap
parent-directory
server
serving-hostname>>
server
insecure>>
"1%-69s\t%s\t%s\t%d\r\n"
sprintf
utf8
encode
write
]
unless-empty
]
bi
path
[
[
name>>
"."
head?
]
reject
[
{
[
directory?
]
[
regular-file?
]
}
1||
]
filter
[
name>>
]
sort-by
[
[
gopher-type
]
[
name>>
]
[
directory?
[
"/"
append
]
when
]
tri
[
dup
file-info
[
file-modified
]
[
file-size
]
bi
"%-40s %s %10s"
sprintf
]
[
path
prepend-path
server
serving-directory>>
?head
drop
url-encode
]
bi
server
serving-hostname>>
server
insecure>>
"%s%s\t%s\t%s\t%d\r\n"
sprintf
utf8
encode
write
]
each
]
with-directory-entries
;