Bug: OS::MemoryMappedFile::open() should not truncate a pre-existing file.
Patch by Mark Lam from Hewlett-Packard Development Company, LP Review URL: http://codereview.chromium.org/6543039 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6872 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
123dbb2f5e
commit
3eb151ebea
@ -209,7 +209,7 @@ class PosixMemoryMappedFile : public OS::MemoryMappedFile {
|
||||
|
||||
|
||||
OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
|
||||
FILE* file = fopen(name, "w+");
|
||||
FILE* file = fopen(name, "r+");
|
||||
if (file == NULL) return NULL;
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
|
@ -224,7 +224,7 @@ class PosixMemoryMappedFile : public OS::MemoryMappedFile {
|
||||
|
||||
|
||||
OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
|
||||
FILE* file = fopen(name, "w+");
|
||||
FILE* file = fopen(name, "r+");
|
||||
if (file == NULL) return NULL;
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
|
@ -327,7 +327,7 @@ class PosixMemoryMappedFile : public OS::MemoryMappedFile {
|
||||
|
||||
|
||||
OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
|
||||
FILE* file = fopen(name, "w+");
|
||||
FILE* file = fopen(name, "r+");
|
||||
if (file == NULL) return NULL;
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
|
@ -205,7 +205,7 @@ class PosixMemoryMappedFile : public OS::MemoryMappedFile {
|
||||
|
||||
|
||||
OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
|
||||
FILE* file = fopen(name, "w+");
|
||||
FILE* file = fopen(name, "r+");
|
||||
if (file == NULL) return NULL;
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
|
@ -222,7 +222,7 @@ class PosixMemoryMappedFile : public OS::MemoryMappedFile {
|
||||
|
||||
|
||||
OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
|
||||
FILE* file = fopen(name, "w+");
|
||||
FILE* file = fopen(name, "r+");
|
||||
if (file == NULL) return NULL;
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
|
@ -235,7 +235,7 @@ class PosixMemoryMappedFile : public OS::MemoryMappedFile {
|
||||
|
||||
|
||||
OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
|
||||
FILE* file = fopen(name, "w+");
|
||||
FILE* file = fopen(name, "r+");
|
||||
if (file == NULL) return NULL;
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
|
@ -939,7 +939,7 @@ OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
|
||||
// Open a physical file
|
||||
HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
|
||||
if (file == NULL) return NULL;
|
||||
if (file == INVALID_HANDLE_VALUE) return NULL;
|
||||
|
||||
int size = static_cast<int>(GetFileSize(file, NULL));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user