| 140 | } |
| 141 | |
| 142 | static OSErr |
| 143 | copy_file(short src_vol, long src_dir, short dst_vol, long dst_dir, |
| 144 | Str255 fName, |
| 145 | pascal OSErr (*opener)(short vRefNum, long dirID, |
| 146 | ConstStr255Param fileName, |
| 147 | signed char permission, short *refNum)) |
| 148 | { |
| 149 | short src_ref, dst_ref; |
| 150 | OSErr err = (*opener)(src_vol, src_dir, fName, fsRdPerm, &src_ref); |
| 151 | if (err == noErr) { |
| 152 | err = (*opener)(dst_vol, dst_dir, fName, fsWrPerm, &dst_ref); |
| 153 | if (err == noErr) { |
| 154 | long file_len; |
| 155 | err = GetEOF(src_ref, &file_len); |
| 156 | if (err == noErr) { |
| 157 | Handle buf; |
| 158 | long count = MaxBlock(); |
| 159 | if (count > file_len) |
| 160 | count = file_len; |
| 161 | |
| 162 | buf = NewHandle(count); |
| 163 | err = MemError(); |
| 164 | if (err == noErr) { |
| 165 | while (count > 0) { |
| 166 | OSErr rd_err = FSRead(src_ref, &count, *buf); |
| 167 | err = FSWrite(dst_ref, &count, *buf); |
| 168 | if (err == noErr) |
| 169 | err = rd_err; |
| 170 | file_len -= count; |
| 171 | } |
| 172 | if (file_len == 0) |
| 173 | err = noErr; |
| 174 | |
| 175 | DisposeHandle(buf); |
| 176 | } |
| 177 | } |
| 178 | FSClose(dst_ref); |
| 179 | } |
| 180 | FSClose(src_ref); |
| 181 | } |
| 182 | |
| 183 | return err; |
| 184 | } |
| 185 | |
| 186 | static void |
| 187 | force_hdelete(short vol, long dir, Str255 fName) |