]> gitweb.factorcode.org Git - factor.git/blob - basis/vocabs/files/files.factor
io.files: exists? -> file-exists? and rename primitive.
[factor.git] / basis / vocabs / files / files.factor
1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: combinators io.directories io.files io.pathnames kernel
4 make sequences splitting vocabs vocabs.loader ;
5 IN: vocabs.files
6
7 : vocab-tests-path ( vocab -- path/f )
8     dup "-tests.factor" append-vocab-dir vocab-append-path ;
9
10 : vocab-tests-dir ( vocab -- paths )
11     dup vocab-dir "tests" append-path vocab-append-path [
12         dup file-exists? [
13             dup directory-files [ ".factor" tail? ] filter
14             [ append-path ] with map
15         ] [ drop f ] if
16     ] [ f ] if* ;
17
18 : vocab-tests ( vocab -- paths )
19     vocab-name ".private" ?tail drop
20     [
21         [ vocab-tests-path [ dup file-exists? [ , ] [ drop ] if ] when* ]
22         [ vocab-tests-dir % ] bi
23     ] { } make ;
24
25 : vocab-files ( vocab -- paths )
26     [
27         {
28             [ vocab-source-path [ , ] when* ]
29             [ vocab-docs-path [ , ] when* ]
30             [ vocab-tests % ]
31         } cleave
32     ] { } make ;