1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 fun test_path
(p
: Path)
18 print
"simplified: {p.simplified}"
19 print
"filename: {p.filename}"
23 print
" error? {p.last_error or else "nope"}"
28 print
"stat: is_dir={s.is_dir} is_reg={s.is_reg}"
30 print
" error? {p.last_error or else "nope"}"
31 var stream
= p
.open_ro
32 print
"open: {stream.path or else "-"}"
33 print
" error? {p.last_error or else "nope"}"
34 print
"first_line: {stream.read_line}"
36 print
" error? {stream.last_error or else "nope"}"
38 print
"content: {txt.length} chars"
39 print
" error? {p.last_error or else "nope"}"
40 var bin
= p
.read_all_bytes
41 print
"content: {bin.length} bytes"
42 print
" error? {p.last_error or else "nope"}"
43 var lines
= p
.read_lines
44 print
"content: {lines.length} lines"
45 print
" error? {p.last_error or else "nope"}"
48 print
"content: {files.length} files"
49 print
" error? {p.last_error or else "nope"}"
52 if args
.length
!= 1 then
53 print
"require the name of the output directory"
59 test_path
(base
.to_path
)
61 var f
= (base
/"file.txt").to_path
64 "hello world!".write_to_file
(f
.to_s
)
70 "goodby world!".write_to_file
(dn
/"file.txt")