Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty Files not working #64

Closed
PSeitz opened this issue Mar 18, 2018 · 2 comments
Closed

Empty Files not working #64

PSeitz opened this issue Mar 18, 2018 · 2 comments

Comments

@PSeitz
Copy link

PSeitz commented Mar 18, 2018

Hi, there seems to be an issue when, a Mmap is created and on an empty file.
I get an "The volume for a file has been externally altered so that the opened file is no longer valid." error under windows.

You can add this to the tests to reproduce.
I also noticed the offset test is not working on Windows.

use std::fs::File;
#[test]
fn map_empty_file_copy() {
    let tempdir = tempdir::TempDir::new("mmap").unwrap();
    let path = tempdir.path().join("mmap");

    let file = OpenOptions::new()
        .read(true)
        .write(true)
        .create(true)
        .open(&path)
        .unwrap();

    let get_mmap = |file:&File| -> Mmap {
        unsafe { Mmap::map(&file).unwrap() }
    };

    let mmap = get_mmap(&file);
}

@PSeitz PSeitz changed the title Empty Files not working, when moving Mmap Empty Files not working when moving Mmap Mar 18, 2018
@BurntSushi
Copy link
Collaborator

I don't think you can memory map an empty file.

@PSeitz PSeitz changed the title Empty Files not working when moving Mmap Empty Files not working Mar 18, 2018
@PSeitz
Copy link
Author

PSeitz commented Mar 18, 2018

I see, there is already a test for this. Is there a way to append to a file via mmap?

@PSeitz PSeitz closed this as completed Jun 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants