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::MapFileToMemory(const FilePath& file_name) { | 776 bool MemoryMappedFile::MapFileToMemoryInternal() { |
777 file_ = ::CreateFile(file_name.value().c_str(), GENERIC_READ, | |
778 FILE_SHARE_READ, NULL, OPEN_EXISTING, | |
779 FILE_ATTRIBUTE_NORMAL, NULL); | |
780 if (file_ == INVALID_HANDLE_VALUE) | 777 if (file_ == INVALID_HANDLE_VALUE) |
781 return false; | 778 return false; |
782 | 779 |
783 length_ = ::GetFileSize(file_, NULL); | 780 length_ = ::GetFileSize(file_, NULL); |
784 if (length_ == INVALID_FILE_SIZE) | 781 if (length_ == INVALID_FILE_SIZE) |
785 return false; | 782 return false; |
786 | 783 |
787 file_mapping_ = ::CreateFileMapping(file_, NULL, PAGE_READONLY, | 784 file_mapping_ = ::CreateFileMapping(file_, NULL, PAGE_READONLY, |
788 0, length_, NULL); | 785 0, length_, NULL); |
789 if (file_mapping_ == INVALID_HANDLE_VALUE) | 786 if (file_mapping_ == INVALID_HANDLE_VALUE) |
(...skipping 11 matching lines...) Expand all Loading... |
801 ::CloseHandle(file_mapping_); | 798 ::CloseHandle(file_mapping_); |
802 if (file_ != INVALID_HANDLE_VALUE) | 799 if (file_ != INVALID_HANDLE_VALUE) |
803 ::CloseHandle(file_); | 800 ::CloseHandle(file_); |
804 | 801 |
805 data_ = NULL; | 802 data_ = NULL; |
806 file_mapping_ = file_ = INVALID_HANDLE_VALUE; | 803 file_mapping_ = file_ = INVALID_HANDLE_VALUE; |
807 length_ = INVALID_FILE_SIZE; | 804 length_ = INVALID_FILE_SIZE; |
808 } | 805 } |
809 | 806 |
810 } // namespace file_util | 807 } // namespace file_util |
OLD | NEW |