Blob Blame History Raw
From 0f5000c31db77cc4352f573eadd637958cf6b94c Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Date: Fri, 5 Jan 2018 21:10:04 +0100
Subject: [PATCH] bump memmap to 0.6

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
---
 src/lib.rs | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/lib.rs b/src/lib.rs
index 99c911b..55ea1c6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -41,6 +41,7 @@ use owning_ref::OwningHandle;
 use fallible_iterator::FallibleIterator;
 
 use std::fmt;
+use std::fs::File;
 use std::path;
 use std::error;
 use std::borrow::Cow;
@@ -232,12 +233,12 @@ impl Mapping {
     }
 
     fn new_inner(file_path: &path::Path, opts: Options) -> Result<Mapping> {
-        let file = memmap::Mmap::open_path(file_path, memmap::Protection::Read)
-            .map_err(|e| ErrorKind::BadPath(e))?;
+        let file = File::open(file_path).map_err(ErrorKind::BadPath)?;
+        let map = unsafe { memmap::Mmap::map(&file).map_err(ErrorKind::BadPath)? };
 
-        OwningHandle::try_new(Box::new(file), |mmap| -> Result<_> {
+        OwningHandle::try_new(Box::new(map), |mmap| -> Result<_> {
             let mmap: &memmap::Mmap = unsafe { &*mmap };
-            let bytes = unsafe { mmap.as_slice() };
+            let bytes = &*mmap;
             EndianDebugInfo::new(bytes, opts)
                 .chain_err(|| "failed to analyze debug information")
                 .map(|di| Box::new(di))
-- 
2.15.1