| 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <psapi.h> | 8 #include <psapi.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #include <shlobj.h> | 10 #include <shlobj.h> |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 return true; | 405 return true; |
| 406 } | 406 } |
| 407 } | 407 } |
| 408 | 408 |
| 409 // TODO(rkc): Work out if we want to handle NTFS junctions here or not, handle | 409 // TODO(rkc): Work out if we want to handle NTFS junctions here or not, handle |
| 410 // them if we do decide to. | 410 // them if we do decide to. |
| 411 bool IsLink(const FilePath& file_path) { | 411 bool IsLink(const FilePath& file_path) { |
| 412 return false; | 412 return false; |
| 413 } | 413 } |
| 414 | 414 |
| 415 bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* results) { | 415 bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* info) { |
| 416 base::ThreadRestrictions::AssertIOAllowed(); | 416 base::ThreadRestrictions::AssertIOAllowed(); |
| 417 if (!info) |
| 418 return false; |
| 417 | 419 |
| 418 WIN32_FILE_ATTRIBUTE_DATA attr; | 420 WIN32_FILE_ATTRIBUTE_DATA attr; |
| 419 if (!GetFileAttributesEx(file_path.value().c_str(), | 421 if (!GetFileAttributesEx(file_path.value().c_str(), |
| 420 GetFileExInfoStandard, &attr)) { | 422 GetFileExInfoStandard, &attr)) { |
| 421 return false; | 423 return false; |
| 422 } | 424 } |
| 423 | 425 |
| 424 ULARGE_INTEGER size; | 426 ULARGE_INTEGER size; |
| 425 size.HighPart = attr.nFileSizeHigh; | 427 size.HighPart = attr.nFileSizeHigh; |
| 426 size.LowPart = attr.nFileSizeLow; | 428 size.LowPart = attr.nFileSizeLow; |
| 427 results->size = size.QuadPart; | 429 info->size = size.QuadPart; |
| 428 | 430 |
| 429 results->is_directory = | 431 info->is_directory = |
| 430 (attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; | 432 (attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; |
| 431 results->last_modified = base::Time::FromFileTime(attr.ftLastWriteTime); | |
| 432 results->last_accessed = base::Time::FromFileTime(attr.ftLastAccessTime); | |
| 433 results->creation_time = base::Time::FromFileTime(attr.ftCreationTime); | |
| 434 | 433 |
| 434 // TODO(gavinp): What about reparse points? |
| 435 info->is_symbolic_link = false; // Windows doesn't have symbolic links. |
| 436 |
| 437 info->last_modified = base::Time::FromFileTime(attr.ftLastWriteTime); |
| 438 info->last_accessed = base::Time::FromFileTime(attr.ftLastAccessTime); |
| 439 info->creation_time = base::Time::FromFileTime(attr.ftCreationTime); |
| 435 return true; | 440 return true; |
| 436 } | 441 } |
| 437 | 442 |
| 438 FILE* OpenFile(const FilePath& filename, const char* mode) { | 443 FILE* OpenFile(const FilePath& filename, const char* mode) { |
| 439 base::ThreadRestrictions::AssertIOAllowed(); | 444 base::ThreadRestrictions::AssertIOAllowed(); |
| 440 std::wstring w_mode = ASCIIToWide(std::string(mode)); | 445 std::wstring w_mode = ASCIIToWide(std::string(mode)); |
| 441 return _wfsopen(filename.value().c_str(), w_mode.c_str(), _SH_DENYNO); | 446 return _wfsopen(filename.value().c_str(), w_mode.c_str(), _SH_DENYNO); |
| 442 } | 447 } |
| 443 | 448 |
| 444 FILE* OpenFile(const std::string& filename, const char* mode) { | 449 FILE* OpenFile(const std::string& filename, const char* mode) { |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 // Like Move, this function is not transactional, so we just | 755 // Like Move, this function is not transactional, so we just |
| 751 // leave the copied bits behind if deleting from_path fails. | 756 // leave the copied bits behind if deleting from_path fails. |
| 752 // If to_path exists previously then we have already overwritten | 757 // If to_path exists previously then we have already overwritten |
| 753 // it by now, we don't get better off by deleting the new bits. | 758 // it by now, we don't get better off by deleting the new bits. |
| 754 } | 759 } |
| 755 return false; | 760 return false; |
| 756 } | 761 } |
| 757 | 762 |
| 758 } // namespace internal | 763 } // namespace internal |
| 759 } // namespace base | 764 } // namespace base |
| OLD | NEW |