1 USING: arrays combinators destructors grouping io io.directories
2 io.encodings.ascii io.encodings.utf8 io.files io.files.info
3 io.files.unique io.launcher io.pathnames kernel math namespaces
4 sequences sorting splitting splitting.monotonic strings system
9 "." directory-files [ "kernel" = ] filter
15 "." directory-files [ "kernel" = ] filter
22 ] with-directory-files
27 "blahblah" make-directory
28 "blahblah" file-exists?
29 "blahblah" file-info directory?
30 "blahblah" delete-directory
31 "blahblah" file-exists?
34 { "file1 contents" } [
35 "file1 contents" "file1" utf8 set-file-contents
36 "file1" "file2" copy-file
37 "file2" utf8 file-contents
42 { "file3 contents" } [
43 "file3 contents" "file3" utf8 set-file-contents
44 "file3" "file4" move-file
45 "file4" utf8 file-contents
56 "file6" link-info drop
61 "test-foo.txt" ascii set-file-lines
65 "test-foo.txt" ascii [
66 "Hello appender." print
71 "test-bar.txt" ascii [
72 "Hello appender." print
76 { "Hello world.\nHello appender.\n" } [
77 "test-foo.txt" ascii file-contents
80 { "Hello appender.\n" } [
81 "test-bar.txt" ascii file-contents
84 { } [ "test-foo.txt" delete-file ] unit-test
85 { } [ "test-bar.txt" delete-file ] unit-test
87 { f } [ "test-foo.txt" file-exists? ] unit-test
88 { f } [ "test-bar.txt" file-exists? ] unit-test
90 { } [ "test-blah" make-directory ] unit-test
93 "test-blah/fooz" ascii <file-writer> dispose
97 "test-blah/fooz" file-exists?
100 { } [ "test-blah/fooz" delete-file ] unit-test
101 { } [ "test-blah" delete-directory ] unit-test
103 { f } [ "test-blah" file-exists? ] unit-test
105 { } [ "delete-tree-test/a/b/c" make-directories ] unit-test
108 { "Hi" } "delete-tree-test/a/b/c/d" ascii set-file-lines
111 { } [ "delete-tree-test" delete-tree ] unit-test
114 "copy-tree-test/a/b/c" make-directories
119 "copy-tree-test/a/b/c/d"
120 ascii set-file-contents
124 "copy-tree-test" "copy-destination" copy-tree
128 "copy-destination/a/b/c/d" ascii file-contents
132 "copy-destination" delete-tree
136 "copy-tree-test" "copy-destination" copy-tree-into
140 "copy-destination/copy-tree-test/a/b/c/d" ascii file-contents
145 "resource:LICENSE.txt" "test" copy-file
150 "copy-destination/copy-tree-test/a/b/c/d" "." copy-file-into
154 "d" ascii file-contents
157 { } [ "d" delete-file ] unit-test
159 { } [ "copy-destination" delete-tree ] unit-test
161 { } [ "copy-tree-test" delete-tree ] unit-test
165 "foo" [ make-directories ] keep
168 vm-path "-e=USE: io.directories \"bar\" touch-file" 2array try-output-process
174 "one/two/three" make-parent-directories parent-directory file-exists?
177 ] with-test-directory
181 10 [ "io.paths.test" "gogogo" unique-file ] replicate
182 "." [ ] find-files [ absolute-path ] map [ natural-sort ] same?
183 ] with-test-directory
187 { "omg you shoudnt have a directory called this" "or this" }
188 [ "asdfasdfasdfasdfasdf" tail? ] find-file-in-directories
192 { } [ "asdfasdfasdfasdfasdf" tail? ] find-file-in-directories
197 "the-head" "" unique-file drop
198 "." [ file-name "the-head" head? ] find-file string?
199 ] with-test-directory
205 [ [ make-directory ] each ]
206 [ [ "abcd" append-path touch-file ] each ]
207 [ [ file-name "abcd" = ] find-files-in-directories length 2 = ]
208 [ [ delete-tree ] each ]
210 ] with-test-directory
214 "resource:core/math/integers/integers.factor"
215 [ "math.factor" tail? ] find-up-to-root >boolean
219 "resource:core/math/integers/integers.factor"
220 [ drop f ] find-up-to-root
276 +depth-first+ traversal-method [
277 "." recursive-directory-files
278 current-directory get '[ _ ?head drop ] map
280 ! preserve file traversal order, but sort
281 ! alphabetically for cross-platform testing
282 dup length 3 / group natural-sort
283 [ natural-sort ] map concat
286 +breadth-first+ traversal-method [
287 "." recursive-directory-files
288 current-directory get '[ _ ?head drop ] map
290 ! preserve file traversal order, but sort
291 ! alphabetically for cross-platform testing
292 [ [ length ] bi@ = ] monotonic-split
293 [ natural-sort ] map concat
295 ] with-test-directory