| iMatix home page | << | < | > | >> |
SFL Version 2.11 |
#include "sflfile.h" int file_concat ( const char *src, const char *dest)
Copies the contents of src onto dest. If dest does not exist, it is created. Returns 0 if the concatenation operation succeeded, or -1 if some error occurred.
{ FILE *inf, *outf; char *buffer; size_t chars_read; /* Amount read from stream */ int feedback = 0; ASSERT (src); ASSERT (dest); # if (defined (MSDOS_FILESYSTEM)) if (system_devicename (dest) || system_devicename (src)) return (-1); /* Not allowed on device names */ # endif if ((inf = fopen (src, FOPEN_READ_BINARY)) == NULL) return (-1); /* Input file not found */ if ((buffer = mem_alloc (SHRT_MAX)) == NULL) feedback = -1; /* Insufficient memory for buffer */ else { if ((outf = fopen (dest, FOPEN_APPEND_BINARY)) == NULL) { mem_free (buffer); return (-1); /* Could not create output file */ } while ((chars_read = fread (buffer, 1, SHRT_MAX, inf)) != 0) if (fwrite (buffer, 1, chars_read, outf) != chars_read) { feedback = -1; break; } fclose (outf); mem_free (buffer); } fclose (inf); return (feedback); }
| << | < | > | >> | Copyright © 1996-2000 iMatix Corporation |