Pol
Revision:cb584c9
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
filecont.cpp
Go to the documentation of this file.
1
7
#include "
filecont.h
"
8
9
#include <cstdio>
10
11
#include "
logfacility.h
"
12
13
namespace
Pol
14
{
15
namespace
Clib
16
{
23
FileContents::FileContents
(
const
char
* filename )
24
{
25
FILE* fp = fopen( filename,
"rb"
);
26
if
( fp == NULL )
27
{
28
ERROR_PRINT
<<
"Unable to open '"
<< filename <<
"' for reading.\n"
;
29
throw
std::runtime_error(
"Error opening file"
);
30
}
31
32
char
buf[1024];
33
while
( !ferror( fp ) && !feof( fp ) )
34
{
35
size_t
nread = fread( buf, 1,
sizeof
buf, fp );
36
if
( nread )
37
contents_
.append( buf, nread );
38
}
39
40
fclose( fp );
41
}
42
46
const
char
*
FileContents::contents
()
const
47
{
48
return
contents_
.c_str();
49
}
50
54
void
FileContents::set_contents
(
const
std::string& str )
55
{
56
contents_
= str;
57
}
58
}
59
}
logfacility.h
Pol::Clib::FileContents::contents
const char * contents() const
Definition:
filecont.cpp:46
filecont.h
Pol::Clib::FileContents::contents_
std::string contents_
Definition:
filecont.h:21
Pol::Clib::FileContents::FileContents
FileContents(const char *filname)
Definition:
filecont.cpp:23
Pol::Clib::FileContents::set_contents
void set_contents(const std::string &str)
Definition:
filecont.cpp:54
ERROR_PRINT
#define ERROR_PRINT
Definition:
logfacility.h:230
Pol
Definition:
berror.cpp:12
clib
filecont.cpp
Generated on Wed Oct 10 2018 02:41:47 for Pol by
1.8.11