Handbook
Glossary
append-path ( path1 path2 -- path )
Factor handbook
»
Input and output
»
Pathnames
Prev:
prepend-path ( path1 path2 -- path )
Next:
normalize-path ( path -- path' )
Vocabulary
io
.
pathnames
Inputs
path1
a pathname string
path2
a pathname string
Outputs
path
a pathname string
Word description
Appends
path1
and
path2
to form a pathname.
Examples
USING: io.pathnames prettyprint ; "first" "second.txt" append-path .
"first/second.txt"
See also
prepend-path
Definition
USING:
combinators
io.pathnames.private
kernel
sequences
;
IN:
io.pathnames
:
append-path
( path1 path2 -- path )
[
pathname>
]
bi@
{
{
[
over
empty?
]
[
append-path-empty
]
}
{
[
dup
empty?
]
[
drop
]
}
{
[
over
trim-tail-separators
"."
=
]
[
nip
]
}
{
[
dup
absolute-path?
]
[
nip
]
}
{
[
dup
head.?
]
[
rest
trim-head-separators
append-path
]
}
{
[
dup
head..?
]
[
2
tail
trim-head-separators
[
parent-directory
]
dip
append-path
]
}
{
[
over
absolute-path?
over
first
path-separator?
and
]
[
[
2
head
]
dip
append
]
}
[
append-relative-path
]
}
cond
;