OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <io.h> |
| 8 |
7 #include "base/file_path.h" | 9 #include "base/file_path.h" |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 #include "base/threading/thread_restrictions.h" | 11 #include "base/threading/thread_restrictions.h" |
10 | 12 |
11 namespace base { | 13 namespace base { |
12 PlatformFile CreatePlatformFileUnsafe(const FilePath& name, | 14 PlatformFile CreatePlatformFileUnsafe(const FilePath& name, |
13 int flags, | 15 int flags, |
14 bool* created, | 16 bool* created, |
15 PlatformFileError* error) { | 17 PlatformFileError* error) { |
16 base::ThreadRestrictions::AssertIOAllowed(); | 18 base::ThreadRestrictions::AssertIOAllowed(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 break; | 104 break; |
103 default: | 105 default: |
104 *error = PLATFORM_FILE_ERROR_FAILED; | 106 *error = PLATFORM_FILE_ERROR_FAILED; |
105 } | 107 } |
106 } | 108 } |
107 } | 109 } |
108 | 110 |
109 return file; | 111 return file; |
110 } | 112 } |
111 | 113 |
| 114 FILE* FdopenPlatformFile(PlatformFile file, const char* mode) { |
| 115 if (file == kInvalidPlatformFileValue) |
| 116 return NULL; |
| 117 int fd = _open_osfhandle(reinterpret_cast<intptr_t>(file), 0); |
| 118 if (fd < 0) |
| 119 return NULL; |
| 120 return _fdopen(fd, mode); |
| 121 } |
| 122 |
112 bool ClosePlatformFile(PlatformFile file) { | 123 bool ClosePlatformFile(PlatformFile file) { |
113 base::ThreadRestrictions::AssertIOAllowed(); | 124 base::ThreadRestrictions::AssertIOAllowed(); |
114 return (CloseHandle(file) != 0); | 125 return (CloseHandle(file) != 0); |
115 } | 126 } |
116 | 127 |
117 int64 SeekPlatformFile(PlatformFile file, | 128 int64 SeekPlatformFile(PlatformFile file, |
118 PlatformFileWhence whence, | 129 PlatformFileWhence whence, |
119 int64 offset) { | 130 int64 offset) { |
120 base::ThreadRestrictions::AssertIOAllowed(); | 131 base::ThreadRestrictions::AssertIOAllowed(); |
121 if (file < 0 || offset < 0) | 132 if (file < 0 || offset < 0) |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 info->is_directory = | 264 info->is_directory = |
254 (file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; | 265 (file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; |
255 info->is_symbolic_link = false; // Windows doesn't have symbolic links. | 266 info->is_symbolic_link = false; // Windows doesn't have symbolic links. |
256 info->last_modified = base::Time::FromFileTime(file_info.ftLastWriteTime); | 267 info->last_modified = base::Time::FromFileTime(file_info.ftLastWriteTime); |
257 info->last_accessed = base::Time::FromFileTime(file_info.ftLastAccessTime); | 268 info->last_accessed = base::Time::FromFileTime(file_info.ftLastAccessTime); |
258 info->creation_time = base::Time::FromFileTime(file_info.ftCreationTime); | 269 info->creation_time = base::Time::FromFileTime(file_info.ftCreationTime); |
259 return true; | 270 return true; |
260 } | 271 } |
261 | 272 |
262 } // namespace base | 273 } // namespace base |
OLD | NEW |