Fix too many ]s in try
[tcl-tlc-base.git] / scripts / fileio.tcl
blobe9906d37bd0e47d3c81e3e8bab677db844840b57
1 # vim: ft=tcl foldmethod=marker foldmarker=<<<,>>> ts=4 shiftwidth=4
3 proc tlc::readfile {fn {mode "text"}} { #<<<
4 set fp [open $fn r]
5 switch -- $mode {
6 text {}
8 binary {
9 fconfigure $fp -encoding binary -translation binary
12 default {
13 error "Invalid mode: \"$mode\"" "" [list invalid_mode $mode]
17 set dat [read $fp]
18 close $fp
20 return $dat
23 #>>>
24 proc tlc::writefile {fn dat {mode "text"}} { #<<<
25 set fp [open $fn w]
26 switch -- $mode {
27 text {}
29 binary {
30 fconfigure $fp -encoding binary -translation binary
33 default {
34 error "Invalid mode: \"$mode\"" "" [list invalid_mode $mode]
38 puts -nonewline $fp $dat
39 close $fp
42 #>>>