Switch to unified view

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