mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'christof/plugin_hotfix' into 'master'
replace read_at with the more portable workaround See merge request veloren/veloren!4146
This commit is contained in:
commit
1950ee9e9b
@ -5,8 +5,8 @@ use tar::EntryType;
|
||||
use std::{
|
||||
fmt,
|
||||
fs::File,
|
||||
hash, io,
|
||||
os::unix::prelude::FileExt,
|
||||
hash,
|
||||
io::{self, Read, Seek, SeekFrom},
|
||||
path::{self, Path, PathBuf},
|
||||
};
|
||||
|
||||
@ -117,10 +117,12 @@ struct Backend(PathBuf);
|
||||
|
||||
impl Backend {
|
||||
fn read(&self, pos: u64, len: usize) -> std::io::Result<Vec<u8>> {
|
||||
File::open(self.0.clone()).and_then(|file| {
|
||||
let mut result = vec![0; len];
|
||||
file.read_exact_at(result.as_mut_slice(), pos)
|
||||
.map(move |_num_bytes| result)
|
||||
File::open(self.0.clone()).and_then(|mut file| {
|
||||
file.seek(SeekFrom::Start(pos)).and_then(|_| {
|
||||
let mut result = vec![0; len];
|
||||
file.read_exact(result.as_mut_slice())
|
||||
.map(move |_num_bytes| result)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user