MCPcopy Create free account
hub / github.com/NetHack/NetHack / CopyFile

Function CopyFile

sys/amiga/amidos.c:251–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249#define COPYSIZE 4096
250
251char *CopyFile(const char *from, const char *to)
252{
253 BPTR fromFile, toFile;
254 char *buffer;
255 long size;
256 char *error = NULL;
257
258 buffer = (char *) alloc(COPYSIZE);
259 if (fromFile = Open( (char *)from, MODE_OLDFILE)) {
260 if (toFile = Open( (char *)to, MODE_NEWFILE)) {
261 while (size = Read(fromFile, buffer, (long)COPYSIZE)) {
262 if (size == -1){
263 error = "Read error";
264 break;
265 }
266 if (size != Write(toFile, buffer, size)) {
267 error = "Write error";
268 break;
269 }
270 }
271 Close(toFile);
272 } else
273 error = "Cannot open destination";
274 Close(fromFile);
275 } else
276 error = "Cannot open source (this should not occur)";
277 free(buffer);
278 return error;
279}
280#endif
281
282#ifdef MFLOPPY

Callers

nothing calls this directly

Calls 1

allocFunction · 0.70

Tested by

no test coverage detected