| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 #include <shlobj.h> | 9 #include <shlobj.h> |
| 10 #include <time.h> | 10 #include <time.h> |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 /////////////////////////////////////////////// | 766 /////////////////////////////////////////////// |
| 767 // MemoryMappedFile | 767 // MemoryMappedFile |
| 768 | 768 |
| 769 MemoryMappedFile::MemoryMappedFile() | 769 MemoryMappedFile::MemoryMappedFile() |
| 770 : file_(INVALID_HANDLE_VALUE), | 770 : file_(INVALID_HANDLE_VALUE), |
| 771 file_mapping_(INVALID_HANDLE_VALUE), | 771 file_mapping_(INVALID_HANDLE_VALUE), |
| 772 data_(NULL), | 772 data_(NULL), |
| 773 length_(INVALID_FILE_SIZE) { | 773 length_(INVALID_FILE_SIZE) { |
| 774 } | 774 } |
| 775 | 775 |
| 776 bool MemoryMappedFile::MapFileToMemoryInternal() { | 776 bool MemoryMappedFile::MapFileToMemory(const FilePath& file_name) { |
| 777 file_ = ::CreateFile(file_name.value().c_str(), GENERIC_READ, |
| 778 FILE_SHARE_READ, NULL, OPEN_EXISTING, |
| 779 FILE_ATTRIBUTE_NORMAL, NULL); |
| 777 if (file_ == INVALID_HANDLE_VALUE) | 780 if (file_ == INVALID_HANDLE_VALUE) |
| 778 return false; | 781 return false; |
| 779 | 782 |
| 780 length_ = ::GetFileSize(file_, NULL); | 783 length_ = ::GetFileSize(file_, NULL); |
| 781 if (length_ == INVALID_FILE_SIZE) | 784 if (length_ == INVALID_FILE_SIZE) |
| 782 return false; | 785 return false; |
| 783 | 786 |
| 784 file_mapping_ = ::CreateFileMapping(file_, NULL, PAGE_READONLY, | 787 file_mapping_ = ::CreateFileMapping(file_, NULL, PAGE_READONLY, |
| 785 0, length_, NULL); | 788 0, length_, NULL); |
| 786 if (file_mapping_ == INVALID_HANDLE_VALUE) | 789 if (file_mapping_ == INVALID_HANDLE_VALUE) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 798 ::CloseHandle(file_mapping_); | 801 ::CloseHandle(file_mapping_); |
| 799 if (file_ != INVALID_HANDLE_VALUE) | 802 if (file_ != INVALID_HANDLE_VALUE) |
| 800 ::CloseHandle(file_); | 803 ::CloseHandle(file_); |
| 801 | 804 |
| 802 data_ = NULL; | 805 data_ = NULL; |
| 803 file_mapping_ = file_ = INVALID_HANDLE_VALUE; | 806 file_mapping_ = file_ = INVALID_HANDLE_VALUE; |
| 804 length_ = INVALID_FILE_SIZE; | 807 length_ = INVALID_FILE_SIZE; |
| 805 } | 808 } |
| 806 | 809 |
| 807 } // namespace file_util | 810 } // namespace file_util |
| OLD | NEW |