1 /* 2 3 Miscellaneous file operations 4 5 copyright (c) 2003, 2005, 2006 squell <squell@alumina.nl> 6 7 use, modification, copying and distribution of this software is permitted 8 under the conditions described in the file 'COPYING'. 9 10 Usage: 11 12 FILE *opentemp(const char *hint, char **name) 13 14 generates a temporary file "near" the filename 'hint' using ftemp, stores 15 the name (if != NULL), and returns the open stream. 16 17 int cpfile(const char *srcnam, const char *dstnam) 18 19 copies src to dest, using fcopy. 20 21 int mvfile(const char *srcnam, const char *dstnam) 22 23 moves src to dest, using rename or cpfile. will try to retain the file mode 24 of dstnam when replacing. 25 26 int fcopy(FILE *dest, FILE *src) 27 28 copies (remainder of) file src to dest (both must be opened/usable) 29 returns success or failure 30 31 size_t fpadd(char c, size_t len, FILE *dest) 32 33 writes len times the character c to the file opened as dest. 34 returns number of character actually written 35 36 FILE *ftemp(char *templ, const char *mode) 37 38 behaves like mk(s)temp, but returns a stream opened in mode 39 40 */ 41 42 #ifndef __ZF_FILEOPS_H 43 #define __ZF_FILEOPS_H 44 45 #ifdef __cplusplus 46 extern "C" { 47 #endif 48 49 #include <stdio.h> 50 51 extern int fcopy(FILE *dest, FILE *src); 52 extern size_t fpadd(char c, size_t len, FILE *dest); 53 extern FILE *ftemp(char *templ, const char *mode); 54 55 extern FILE *opentemp(const char *hint, char **name); 56 57 extern int cpfile(const char *srcnam, const char *dstnam); 58 extern int mvfile(const char *srcnam, const char *dstnam); 59 60 #ifdef __cplusplus 61 } 62 #endif 63 #endif 64 65