3 string "I/O error writing file"
11 export sbJ_chdir sbJ_copy sbJ_path_join sbJ_path_split sbJ_rmdir sbJ_unlink sbJ_unlink_recursive
12 import sbJ_eq sbJ_false sbJ_ge sbJ_gt sbJ_le sbJ_lt sbJ_ne sbJ_true
13 import chdir closedir opendir rmdir unlink
14 import sbJ_allocate_bytes sbJ_close_stream sbJ_compare_blobs sbJ_concatenate_blobs sbJ_cstring_from_blob sbJ_error sbJ_input_file sbJ_make_blob sbJ_readdir sbJ_output_file sbJ_read_bytes_from_stream sbJ_split_blob sbJ_stat sbJ_stat_isdir sbJ_write_bytes_to_stream
19 # Changes the current working directory to new_dir.
20 let sbJ__sb_G1 call sbJ_cstring_from_blob sbJ_new_dir
28 function sbJ_source sbJ_dest
30 # Copies source file to dest.
31 let sbJ_infile call sbJ_input_file sbJ_source
32 let sbJ_outfile call sbJ_output_file sbJ_dest
36 let sbJ_buffer call sbJ_allocate_bytes sbJ_size
40 set sbJ_n call sbJ_read_bytes_from_stream sbJ_infile sbJ_buffer sbJ_size
41 let sbJ__sb_G2 call sbJ_gt sbJ_n 0
43 ifeq _sb_G6 @sbJ_false
46 set sbJ_m call sbJ_write_bytes_to_stream sbJ_outfile sbJ_buffer sbJ_n
47 let sbJ__sb_G3 call sbJ_ne sbJ_n sbJ_m
48 ifeq sbJ__sb_G3 @sbJ_true
50 let sbJ__sb_G4 call sbJ_make_blob _sb_G9 22
51 call sbJ_error sbJ__sb_G4
54 let sbJ__sb_G5 call sbJ_eq sbJ_n sbJ_size
56 ifeq _sb_G6 @sbJ_false
62 call sbJ_close_stream sbJ_infile
63 call sbJ_close_stream sbJ_outfile
70 function sbJ_first sbJ_second
72 let sbJ__sb_G10 call sbJ_make_blob _sb_G12 1
73 let sbJ_prefix call sbJ_concatenate_blobs sbJ_first sbJ__sb_G10
74 let sbJ__sb_G11 call sbJ_concatenate_blobs sbJ_prefix sbJ_second
83 # Returns the components of path.
84 let sbJ__sb_G13 call sbJ_split_blob sbJ_path 47
93 # Removes directory path. Only the directory itself is removed,
94 # not its contents, so this will fail if the directory is not empty.
95 # To remove a directory and all its contents, use unlink_recursive.
96 let sbJ__sb_G14 call sbJ_cstring_from_blob sbJ_path
97 let sbJ__sb_G15 call rmdir sbJ__sb_G14
107 let sbJ__sb_G16 call sbJ_cstring_from_blob sbJ_path
108 let sbJ__sb_G17 call unlink sbJ__sb_G16
114 sbJ_unlink_recursive:
117 # Unlinks a path. If the path designates a directory, its contents
118 # are removed, first.
119 let sbJ_cstr call sbJ_cstring_from_blob sbJ_path
120 let sbJ_st call sbJ_stat sbJ_path
121 let sbJ__sb_G18 call sbJ_stat_isdir sbJ_st
122 ifeq sbJ__sb_G18 @sbJ_true
124 # Recursively remove all directory entries.
125 let sbJ_dir call opendir sbJ_cstr
126 let sbJ_dot call sbJ_make_blob _sb_G27 1
127 let sbJ_dotdot call sbJ_make_blob _sb_G28 2
132 set sbJ_name call sbJ_readdir sbJ_dir
133 let sbJ__sb_G19 call sbJ_ne sbJ_name -1
134 set _sb_G29 sbJ__sb_G19
135 ifeq _sb_G29 @sbJ_false
138 let sbJ__sb_G20 call sbJ_compare_blobs sbJ_name sbJ_dot
139 let sbJ__sb_G21 call sbJ_eq sbJ__sb_G20 0
140 ifeq sbJ__sb_G21 @sbJ_true
146 let sbJ__sb_G22 call sbJ_compare_blobs sbJ_name sbJ_dotdot
147 let sbJ__sb_G23 call sbJ_eq sbJ__sb_G22 0
148 ifeq sbJ__sb_G23 @sbJ_true
154 let sbJ__sb_G24 call sbJ_path_join sbJ_path sbJ_name
155 call sbJ_unlink_recursive sbJ__sb_G24
163 call closedir sbJ_dir
164 let sbJ__sb_G25 call sbJ_rmdir sbJ_path
169 let sbJ__sb_G26 call sbJ_unlink sbJ_path