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
parent 123dbb2f
...@@ -209,7 +209,7 @@ class PosixMemoryMappedFile : public OS::MemoryMappedFile { ...@@ -209,7 +209,7 @@ class PosixMemoryMappedFile : public OS::MemoryMappedFile {
OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) { OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
FILE* file = fopen(name, "w+"); FILE* file = fopen(name, "r+");
if (file == NULL) return NULL; if (file == NULL) return NULL;
fseek(file, 0, SEEK_END); fseek(file, 0, SEEK_END);
......
...@@ -224,7 +224,7 @@ class PosixMemoryMappedFile : public OS::MemoryMappedFile { ...@@ -224,7 +224,7 @@ class PosixMemoryMappedFile : public OS::MemoryMappedFile {
OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) { OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
FILE* file = fopen(name, "w+"); FILE* file = fopen(name, "r+");
if (file == NULL) return NULL; if (file == NULL) return NULL;
fseek(file, 0, SEEK_END); fseek(file, 0, SEEK_END);
......
...@@ -327,7 +327,7 @@ class PosixMemoryMappedFile : public OS::MemoryMappedFile { ...@@ -327,7 +327,7 @@ class PosixMemoryMappedFile : public OS::MemoryMappedFile {
OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) { OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
FILE* file = fopen(name, "w+"); FILE* file = fopen(name, "r+");
if (file == NULL) return NULL; if (file == NULL) return NULL;
fseek(file, 0, SEEK_END); fseek(file, 0, SEEK_END);
......
...@@ -205,7 +205,7 @@ class PosixMemoryMappedFile : public OS::MemoryMappedFile { ...@@ -205,7 +205,7 @@ class PosixMemoryMappedFile : public OS::MemoryMappedFile {
OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) { OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
FILE* file = fopen(name, "w+"); FILE* file = fopen(name, "r+");
if (file == NULL) return NULL; if (file == NULL) return NULL;
fseek(file, 0, SEEK_END); fseek(file, 0, SEEK_END);
......
...@@ -222,7 +222,7 @@ class PosixMemoryMappedFile : public OS::MemoryMappedFile { ...@@ -222,7 +222,7 @@ class PosixMemoryMappedFile : public OS::MemoryMappedFile {
OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) { OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
FILE* file = fopen(name, "w+"); FILE* file = fopen(name, "r+");
if (file == NULL) return NULL; if (file == NULL) return NULL;
fseek(file, 0, SEEK_END); fseek(file, 0, SEEK_END);
......
...@@ -235,7 +235,7 @@ class PosixMemoryMappedFile : public OS::MemoryMappedFile { ...@@ -235,7 +235,7 @@ class PosixMemoryMappedFile : public OS::MemoryMappedFile {
OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) { OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
FILE* file = fopen(name, "w+"); FILE* file = fopen(name, "r+");
if (file == NULL) return NULL; if (file == NULL) return NULL;
fseek(file, 0, SEEK_END); fseek(file, 0, SEEK_END);
......
...@@ -939,7 +939,7 @@ OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) { ...@@ -939,7 +939,7 @@ OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
// Open a physical file // Open a physical file
HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE, HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); 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)); int size = static_cast<int>(GetFileSize(file, NULL));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment