25 int fd = ::open(file_name.c_str(), O_RDONLY);
28 << std::strerror(errno));
32 if (fstat(fd, &stats) < 0) {
34 << std::strerror(errno));
36 if ((stats.st_mode & S_IFMT) != S_IFREG) {
38 <<
"' must be a regular file");
40 string content(stats.st_size,
' ');
41 ssize_t got = ::read(fd, &content[0], stats.st_size);
44 << std::strerror(errno));
46 if (got != stats.st_size) {
48 <<
"' (got " << got <<
" of " << stats.st_size <<
")");
50 static_cast<void>(close(fd));
52 }
catch (
const std::exception&) {
53 static_cast<void>(close(fd));
61 if (::stat(name.c_str(), &stats) < 0) {
64 return ((stats.st_mode & S_IFMT) == S_IFDIR);
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
bool isDir(const string &name)
Is a directory predicate.
string getContent(const string &file_name)
Get the content of a regular file.
Defines the logger used by the top-level component of kea-lfc.