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