MCPcopy Create free account
hub / github.com/comaps/comaps / Open

Method Open

libs/coding/files_container.cpp:112–134  ·  view source on GitHub ↗

//////////////////////////////////////////////////////////////////////// MappedFile ////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

110// MappedFile
111/////////////////////////////////////////////////////////////////////////////
112void MappedFile::Open(std::string const & fName)
113{
114 Close();
115
116#ifdef OMIM_OS_WINDOWS
117 m_hFile = CreateFileA(fName.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
118 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);
119 if (m_hFile == INVALID_HANDLE_VALUE)
120 MYTHROW(Reader::OpenException, ("Can't open file:", fName, "win last error:", GetLastError()));
121 m_hMapping = CreateFileMappingA(m_hFile, NULL, PAGE_READONLY, 0, 0, NULL);
122 if (m_hMapping == NULL)
123 MYTHROW(Reader::OpenException, ("Can't create file's Windows mapping:", fName, "win last error:", GetLastError()));
124#else
125 m_fd = open(fName.c_str(), O_RDONLY | O_NONBLOCK);
126 if (m_fd == -1)
127 {
128 if (errno == EMFILE || errno == ENFILE)
129 MYTHROW(Reader::TooManyFilesException, ("Can't open file:", fName, ", reason:", strerror(errno)));
130 else
131 MYTHROW(Reader::OpenException, ("Can't open file:", fName, ", reason:", strerror(errno)));
132 }
133#endif
134}
135
136void MappedFile::Close()
137{

Callers 2

LoadMethod · 0.45
ReconnectMethod · 0.45

Calls 7

CloseFunction · 0.85
LessOffsetClass · 0.85
ASSERTFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected