| 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 return _fdopen(_open_osfhandle(file, 0), mode); |
| 116 } |
| 117 |
| 112 bool ClosePlatformFile(PlatformFile file) { | 118 bool ClosePlatformFile(PlatformFile file) { |
| 113 base::ThreadRestrictions::AssertIOAllowed(); | 119 base::ThreadRestrictions::AssertIOAllowed(); |
| 114 return (CloseHandle(file) != 0); | 120 return (CloseHandle(file) != 0); |
| 115 } | 121 } |
| 116 | 122 |
| 117 int64 SeekPlatformFile(PlatformFile file, | 123 int64 SeekPlatformFile(PlatformFile file, |
| 118 PlatformFileWhence whence, | 124 PlatformFileWhence whence, |
| 119 int64 offset) { | 125 int64 offset) { |
| 120 base::ThreadRestrictions::AssertIOAllowed(); | 126 base::ThreadRestrictions::AssertIOAllowed(); |
| 121 if (file < 0 || offset < 0) | 127 if (file < 0 || offset < 0) |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 info->is_directory = | 259 info->is_directory = |
| 254 (file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; | 260 (file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; |
| 255 info->is_symbolic_link = false; // Windows doesn't have symbolic links. | 261 info->is_symbolic_link = false; // Windows doesn't have symbolic links. |
| 256 info->last_modified = base::Time::FromFileTime(file_info.ftLastWriteTime); | 262 info->last_modified = base::Time::FromFileTime(file_info.ftLastWriteTime); |
| 257 info->last_accessed = base::Time::FromFileTime(file_info.ftLastAccessTime); | 263 info->last_accessed = base::Time::FromFileTime(file_info.ftLastAccessTime); |
| 258 info->creation_time = base::Time::FromFileTime(file_info.ftCreationTime); | 264 info->creation_time = base::Time::FromFileTime(file_info.ftCreationTime); |
| 259 return true; | 265 return true; |
| 260 } | 266 } |
| 261 | 267 |
| 262 } // namespace base | 268 } // namespace base |
| OLD | NEW |