17 : _path{deviceFilePath}, _fd{::open(_path.c_str(), flags)} {
19 std::cout <<
"XDMA: opening device file " << _path << std::endl;
22 throw runtime_error(_strerror(
"Cannot open device: "));
31 std::cout <<
"XDMA: closing device file " << _path << std::endl;
37 std::string DeviceFile::_strerror(
const std::string& msg)
const {
39 return msg + _path +
": " + ::strerror_r(errno, tmp,
sizeof(tmp));
42 DeviceFile::operator int()
const {
52 if(fstat(_fd, &s) != 0) {
56 return s.st_nlink > 0;