8 #include "daq/slc/system/File.h"
10 #include <daq/slc/base/IOException.h>
21 void File::open(
const std::string& path,
const std::string& mode_s)
24 if (mode_s.find(
"w") != std::string::npos) {
26 if (mode_s.find(
"r") != std::string::npos) {
32 if ((m_fd = ::open(path.c_str(), mode, 0666)) < 0) {
34 throw (
IOException(
"Failed to open file : %s", path.c_str()));
38 void File::unlink(
const std::string& path)
40 if ((::unlink(path.c_str())) < 0) {
46 size_t File::write(
const void* buf,
size_t count)
52 ret = ::write(m_fd, ((
unsigned char*)buf + c), (count - c));
70 size_t File::read(
void* buf,
size_t count)
76 ret = ::read(m_fd, ((
unsigned char*)buf + c), (count - c));
80 case EAGAIN:
continue;
82 throw (
IOException(
"Error while reading. %d", errno));
90 bool File::exist(
const std::string& filename)
93 if (stat(filename.c_str(), &st) != 0) {
96 mode_t m = st.st_mode;
Abstract base class for different kinds of events.