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/platform_file.h" | 5 #include "base/platform_file.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 | 9 |
10 namespace base { | 10 namespace base { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 create_flags |= FILE_ATTRIBUTE_TEMPORARY; | 61 create_flags |= FILE_ATTRIBUTE_TEMPORARY; |
62 if (flags & PLATFORM_FILE_HIDDEN) | 62 if (flags & PLATFORM_FILE_HIDDEN) |
63 create_flags |= FILE_ATTRIBUTE_HIDDEN; | 63 create_flags |= FILE_ATTRIBUTE_HIDDEN; |
64 if (flags & PLATFORM_FILE_DELETE_ON_CLOSE) | 64 if (flags & PLATFORM_FILE_DELETE_ON_CLOSE) |
65 create_flags |= FILE_FLAG_DELETE_ON_CLOSE; | 65 create_flags |= FILE_FLAG_DELETE_ON_CLOSE; |
66 | 66 |
67 HANDLE file = CreateFile(name.value().c_str(), access, sharing, NULL, | 67 HANDLE file = CreateFile(name.value().c_str(), access, sharing, NULL, |
68 disposition, create_flags, NULL); | 68 disposition, create_flags, NULL); |
69 | 69 |
70 if (created && (INVALID_HANDLE_VALUE != file)) { | 70 if (created && (INVALID_HANDLE_VALUE != file)) { |
71 if (flags & PLATFORM_FILE_OPEN_ALWAYS) | 71 if (flags & (PLATFORM_FILE_OPEN_ALWAYS)) |
72 *created = (ERROR_ALREADY_EXISTS != GetLastError()); | 72 *created = (ERROR_ALREADY_EXISTS != GetLastError()); |
73 else if (flags & PLATFORM_FILE_CREATE_ALWAYS) | 73 else if (flags & (PLATFORM_FILE_CREATE_ALWAYS | PLATFORM_FILE_CREATE)) |
74 *created = true; | 74 *created = true; |
75 } | 75 } |
76 | 76 |
77 if (error_code) { | 77 if (error_code) { |
78 if (file != kInvalidPlatformFileValue) | 78 if (file != kInvalidPlatformFileValue) |
79 *error_code = PLATFORM_FILE_OK; | 79 *error_code = PLATFORM_FILE_OK; |
80 else { | 80 else { |
81 DWORD last_error = GetLastError(); | 81 DWORD last_error = GetLastError(); |
82 switch (last_error) { | 82 switch (last_error) { |
83 case ERROR_SHARING_VIOLATION: | 83 case ERROR_SHARING_VIOLATION: |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 info->size = size.QuadPart; | 204 info->size = size.QuadPart; |
205 info->is_directory = | 205 info->is_directory = |
206 file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY != 0; | 206 file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY != 0; |
207 info->last_modified = base::Time::FromFileTime(file_info.ftLastWriteTime); | 207 info->last_modified = base::Time::FromFileTime(file_info.ftLastWriteTime); |
208 info->last_accessed = base::Time::FromFileTime(file_info.ftLastAccessTime); | 208 info->last_accessed = base::Time::FromFileTime(file_info.ftLastAccessTime); |
209 info->creation_time = base::Time::FromFileTime(file_info.ftCreationTime); | 209 info->creation_time = base::Time::FromFileTime(file_info.ftCreationTime); |
210 return true; | 210 return true; |
211 } | 211 } |
212 | 212 |
213 } // namespace disk_cache | 213 } // namespace disk_cache |
OLD | NEW |