1 USING: continuations destructors io io.directories
2 io.directories.hierarchy io.encodings.ascii io.encodings.utf8
3 io.files io.files.info io.files.temp io.pathnames kernel
5 IN: io.directories.tests
9 "." directory-files [ "kernel" = ] filter
15 "." directory-files [ "kernel" = ] filter
22 ] with-directory-files
25 [ ] [ "blahblah" temp-file dup exists? [ delete-directory ] [ drop ] if ] unit-test
26 [ ] [ "blahblah" temp-file make-directory ] unit-test
27 [ t ] [ "blahblah" temp-file file-info directory? ] unit-test
30 [ temp-directory "loldir" append-path delete-directory ] ignore-errors
32 "loldir" make-directory
34 temp-directory "loldir" append-path exists?
38 [ temp-directory "loldir" append-path delete-directory ] ignore-errors
40 "loldir" make-directory
41 "loldir" delete-directory
45 [ "file1 contents" ] [
46 [ temp-directory "loldir" append-path delete-directory ] ignore-errors
48 "file1 contents" "file1" utf8 set-file-contents
49 "file1" "file2" copy-file
50 "file2" utf8 file-contents
52 "file1" temp-file delete-file
53 "file2" temp-file delete-file
56 [ "file3 contents" ] [
58 "file3 contents" "file3" utf8 set-file-contents
59 "file3" "file4" move-file
60 "file4" utf8 file-contents
62 "file4" temp-file delete-file
65 [ "file5" temp-file delete-file ] ignore-errors
74 [ "file6" temp-file delete-file ] ignore-errors
79 "file6" link-info drop
85 "test-foo.txt" temp-file ascii set-file-lines
89 "test-foo.txt" temp-file ascii [
90 "Hello appender." print
95 "test-bar.txt" temp-file ascii [
96 "Hello appender." print
100 [ "Hello world.\nHello appender.\n" ] [
101 "test-foo.txt" temp-file ascii file-contents
104 [ "Hello appender.\n" ] [
105 "test-bar.txt" temp-file ascii file-contents
108 [ ] [ "test-foo.txt" temp-file delete-file ] unit-test
110 [ ] [ "test-bar.txt" temp-file delete-file ] unit-test
112 [ f ] [ "test-foo.txt" temp-file exists? ] unit-test
114 [ f ] [ "test-bar.txt" temp-file exists? ] unit-test
116 [ "test-blah" temp-file delete-tree ] ignore-errors
118 [ ] [ "test-blah" temp-file make-directory ] unit-test
121 "test-blah/fooz" temp-file ascii <file-writer> dispose
125 "test-blah/fooz" temp-file exists?
128 [ ] [ "test-blah/fooz" temp-file delete-file ] unit-test
130 [ ] [ "test-blah" temp-file delete-directory ] unit-test
132 [ f ] [ "test-blah" temp-file exists? ] unit-test
134 [ ] [ "delete-tree-test/a/b/c" temp-file make-directories ] unit-test
138 "delete-tree-test/a/b/c/d" temp-file ascii set-file-lines
142 "delete-tree-test" temp-file delete-tree
146 "copy-tree-test/a/b/c" temp-file make-directories
151 "copy-tree-test/a/b/c/d" temp-file
152 ascii set-file-contents
156 "copy-tree-test" temp-file
157 "copy-destination" temp-file copy-tree
161 "copy-destination/a/b/c/d" temp-file ascii file-contents
165 "copy-destination" temp-file delete-tree
169 "copy-tree-test" temp-file
170 "copy-destination" temp-file copy-tree-into
174 "copy-destination/copy-tree-test/a/b/c/d" temp-file ascii file-contents
178 "copy-destination/copy-tree-test/a/b/c/d" temp-file "" temp-file copy-file-into
182 "d" temp-file ascii file-contents
185 [ ] [ "d" temp-file delete-file ] unit-test
187 [ ] [ "copy-destination" temp-file delete-tree ] unit-test
189 [ ] [ "copy-tree-test" temp-file delete-tree ] unit-test