mirror of
https://github.com/ksherlock/dot_clean.git
synced 2024-06-08 15:29:28 +00:00
mapped_file w/ length of 0.
This commit is contained in:
parent
9fa3131909
commit
00c936aaf6
|
@ -48,7 +48,6 @@ void mapped_file_base::open(const path_type& p, mapmode flags, size_t length, si
|
||||||
|
|
||||||
HANDLE fh;
|
HANDLE fh;
|
||||||
HANDLE mh;
|
HANDLE mh;
|
||||||
LARGE_INTEGER file_size;
|
|
||||||
|
|
||||||
// length of 0 in CreateFileMapping / MapViewOfFile
|
// length of 0 in CreateFileMapping / MapViewOfFile
|
||||||
// means map the entire file.
|
// means map the entire file.
|
||||||
|
@ -71,10 +70,12 @@ void mapped_file_base::open(const path_type& p, mapmode flags, size_t length, si
|
||||||
|
|
||||||
auto fh_close = make_unique_resource(fh, CloseHandle);
|
auto fh_close = make_unique_resource(fh, CloseHandle);
|
||||||
|
|
||||||
GetFileSizeEx(fh, &file_size);
|
|
||||||
|
|
||||||
if (length == -1)
|
if (length == -1){
|
||||||
|
LARGE_INTEGER file_size;
|
||||||
|
GetFileSizeEx(fh, &file_size);
|
||||||
length = file_size.QuadPart;
|
length = file_size.QuadPart;
|
||||||
|
}
|
||||||
|
|
||||||
DWORD protect = 0;
|
DWORD protect = 0;
|
||||||
DWORD access = 0;
|
DWORD access = 0;
|
||||||
|
@ -246,7 +247,7 @@ void mapped_file_base::open(const path_type& p, mapmode flags, size_t length, si
|
||||||
|
|
||||||
length = st.st_size;
|
length = st.st_size;
|
||||||
}
|
}
|
||||||
|
if (length == 0) return; // mmap w/ length of 0 is EINVAL.
|
||||||
|
|
||||||
_data = ::mmap(0, length,
|
_data = ::mmap(0, length,
|
||||||
flags == readonly ? PROT_READ : PROT_READ | PROT_WRITE,
|
flags == readonly ? PROT_READ : PROT_READ | PROT_WRITE,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user