Switch to unified view

a/src/utils/readfile.h b/src/utils/readfile.h
...
...
19
/* @(#$Id: readfile.h,v 1.3 2007-06-02 08:30:42 dockes Exp $  (C) 2004 J.F.Dockes */
19
/* @(#$Id: readfile.h,v 1.3 2007-06-02 08:30:42 dockes Exp $  (C) 2004 J.F.Dockes */
20
20
21
#include <string>
21
#include <string>
22
using std::string;
22
using std::string;
23
23
24
/**
24
/** 
25
 * Read whole file into string. 
25
 * Read file in chunks, calling an accumulator for each chunk. Can be used 
26
 * @return true for ok, false else
26
 * for reading in a file, computing an md5...
27
 */
27
 */
28
bool file_to_string(const string &filename, string &data, string *reason = 0);
29
30
class FileScanDo {
28
class FileScanDo {
31
public:
29
public:
32
    virtual ~FileScanDo() {}
30
    virtual ~FileScanDo() {}
33
    virtual bool init(unsigned int size, string *reason) = 0;
31
    virtual bool init(unsigned int size, string *reason) = 0;
34
    virtual bool data(const char *buf, int cnt, string* reason) = 0;
32
    virtual bool data(const char *buf, int cnt, string* reason) = 0;
35
};
33
};
36
bool file_scan(const std::string &filename, FileScanDo* doer,  
34
bool file_scan(const string &filename, FileScanDo* doer, string *reason = 0);
37
         std::string *reason = 0);
35
/* Same but only process count cnt from offset offs. Set cnt to size_t(-1) 
36
 * for no limit */
37
bool file_scan(const string &fn, FileScanDo* doer, off_t offs, size_t cnt,
38
               string *reason = 0);
39
40
/**
41
 * Read file into string.
42
 * @return true for ok, false else
43
 */
44
bool file_to_string(const string &filename, string &data, string *reason = 0);
45
46
/** Read file chunk into string. Set cnt to size_t(-1) for whole file */
47
bool file_to_string(const string &filename, string &data, 
48
                    off_t offs, size_t cnt, string *reason = 0);
38
49
39
#endif /* _READFILE_H_INCLUDED_ */
50
#endif /* _READFILE_H_INCLUDED_ */