25 "Error while reading " << filename <<
": The file does not exist or is not readable.");
27#if defined LINUX || defined MACOSX
33 if (stat(filename, &(this->st)) != 0) {
35 if (stat64(filename, &(this->st)) != 0) {
37 STORM_LOG_THROW(
false, storm::exceptions::FileIoException,
"Error in stat(" << filename <<
"): Probably, this file does not exist.");
39 this->file = open(filename, O_RDONLY);
41 STORM_LOG_THROW(this->file >= 0, storm::exceptions::FileIoException,
"Error in open(" << filename <<
"): Probably, we may not read this file.");
43 this->data =
static_cast<char*
>(mmap(NULL, this->st.st_size, PROT_READ, MAP_PRIVATE, this->file, 0));
44 if (this->data == MAP_FAILED) {
46 STORM_LOG_ERROR(
"Error in mmap(" << filename <<
"): " << std::strerror(errno));
47 throw exceptions::FileIoException() <<
"MappedFile Error in mmap(): " << std::strerror(errno);
49 this->dataEnd = this->data + this->st.st_size;
55 if (_stat64(filename, &(this->st)) != 0) {
56 STORM_LOG_ERROR(
"Error in _stat(" << filename <<
"): Probably, this file does not exist.");
57 throw exceptions::FileIoException(
"MappedFile Error in stat(): Probably, this file does not exist.");
60 this->file = CreateFileA(filename, GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
61 if (this->file == INVALID_HANDLE_VALUE) {
62 STORM_LOG_ERROR(
"Error in CreateFileA(" << filename <<
"): Probably, we may not read this file.");
63 throw exceptions::FileIoException(
"MappedFile Error in CreateFileA(): Probably, we may not read this file.");
66 this->mapping = CreateFileMappingA(this->file, NULL, PAGE_READONLY, (DWORD)(st.st_size >> 32), (DWORD)st.st_size, NULL);
67 if (this->mapping == NULL) {
68 CloseHandle(this->file);
70 throw exceptions::FileIoException(
"MappedFile Error in CreateFileMappingA().");
73 this->data =
static_cast<char*
>(MapViewOfFile(this->mapping, FILE_MAP_READ, 0, 0, this->st.st_size));
74 if (this->data == NULL) {
75 CloseHandle(this->mapping);
76 CloseHandle(this->file);
78 throw exceptions::FileIoException(
"MappedFile Error in MapViewOfFile().");
80 this->dataEnd = this->data + this->st.st_size;