diff --git a/io.cpp b/io.cpp
index 96d2ece1..a0fd3ce5 100644
--- a/io.cpp
+++ b/io.cpp
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with libgim. If not, see .
*
- * Copyright 2010-2012 Danny Robson
+ * Copyright 2010-2014 Danny Robson
*/
#include "io.hpp"
@@ -182,18 +182,8 @@ util::set_cwd (const boost::filesystem::path &path) {
#include
-mapped_file::mapped_file (const char *_path):
- m_fd (open (_path, O_RDONLY))
-{ load_fd (); }
-
-
-mapped_file::mapped_file (const std::string &_path):
- m_fd (open (_path.c_str (), O_RDONLY))
-{ load_fd (); }
-
-
mapped_file::mapped_file (const boost::filesystem::path &_path):
- m_fd (open (_path.native ().c_str (), O_RDONLY))
+ m_fd (open (_path.native ().c_str (), O_RDWR))
{ load_fd (); }
@@ -210,7 +200,7 @@ mapped_file::load_fd (void) {
throw errno_error ();
m_size = (size_t)meta.st_size;
- m_data = (uint8_t *)mmap (NULL, m_size, PROT_READ, MAP_PRIVATE, m_fd, 0);
+ m_data = (uint8_t *)mmap (NULL, m_size, PROT_READ | PROT_WRITE, MAP_SHARED, m_fd, 0);
if (m_data == MAP_FAILED)
throw errno_error ();
}
@@ -225,6 +215,15 @@ mapped_file::size (void) const {
}
+uint8_t*
+mapped_file::data (void) {
+ CHECK (m_size > 0);
+ CHECK (m_data != NULL);
+
+ return m_data;
+}
+
+
const uint8_t*
mapped_file::data (void) const {
CHECK (m_size > 0);
diff --git a/io.hpp b/io.hpp
index d9fd580b..bd262044 100644
--- a/io.hpp
+++ b/io.hpp
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with libgim. If not, see .
*
- * Copyright 2010-2012 Danny Robson
+ * Copyright 2010-2014 Danny Robson
*/
#ifndef __UTIL_IO_HPP
@@ -114,16 +114,15 @@ namespace util {
void load_fd (void);
public:
- mapped_file (const char *path);
- mapped_file (const std::string &path);
mapped_file (const boost::filesystem::path &path);
- mapped_file (const mapped_file &rhs);
- mapped_file& operator =(const mapped_file &rhs);
+ mapped_file (const mapped_file&) = delete;
+ mapped_file& operator= (const mapped_file&) = delete;
~mapped_file ();
const uint8_t* data (void) const;
+ uint8_t* data (void);
size_t size (void) const;
};
#endif