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/files/file_util.h" | 5 #include "base/files/file_util.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <io.h> | 8 #include <io.h> |
9 #include <psapi.h> | 9 #include <psapi.h> |
10 #include <shellapi.h> | 10 #include <shellapi.h> |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 bool success = false; | 552 bool success = false; |
553 HANDLE cp = GetCurrentProcess(); | 553 HANDLE cp = GetCurrentProcess(); |
554 if (::GetMappedFileNameW(cp, file_view, mapped_file_path, kMaxPathLength)) { | 554 if (::GetMappedFileNameW(cp, file_view, mapped_file_path, kMaxPathLength)) { |
555 *nt_path = FilePath(mapped_file_path); | 555 *nt_path = FilePath(mapped_file_path); |
556 success = true; | 556 success = true; |
557 } | 557 } |
558 ::UnmapViewOfFile(file_view); | 558 ::UnmapViewOfFile(file_view); |
559 return success; | 559 return success; |
560 } | 560 } |
561 | 561 |
562 bool IsOnNetworkDrive(const base::FilePath& path) { | |
563 win::ScopedHandle handle( | |
564 ::CreateFileW(path.value().c_str(), | |
565 GENERIC_READ, | |
566 kFileShareAll, | |
567 NULL, | |
568 OPEN_EXISTING, | |
569 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open directory. | |
570 NULL)); | |
571 | |
572 if (!handle.IsValid()) | |
573 return false; | |
574 | |
575 // If able to get network information, then the file is on a network. | |
576 FILE_REMOTE_PROTOCOL_INFO remote_proto_info = {0}; | |
577 return !!::GetFileInformationByHandleEx(handle.Get(), FileRemoteProtocolInfo, | |
578 &remote_proto_info, | |
579 sizeof(remote_proto_info)); | |
580 } | |
581 | |
582 // TODO(rkc): Work out if we want to handle NTFS junctions here or not, handle | 562 // TODO(rkc): Work out if we want to handle NTFS junctions here or not, handle |
583 // them if we do decide to. | 563 // them if we do decide to. |
584 bool IsLink(const FilePath& file_path) { | 564 bool IsLink(const FilePath& file_path) { |
585 return false; | 565 return false; |
586 } | 566 } |
587 | 567 |
588 bool GetFileInfo(const FilePath& file_path, File::Info* results) { | 568 bool GetFileInfo(const FilePath& file_path, File::Info* results) { |
589 ThreadRestrictions::AssertIOAllowed(); | 569 ThreadRestrictions::AssertIOAllowed(); |
590 | 570 |
591 WIN32_FILE_ATTRIBUTE_DATA attr; | 571 WIN32_FILE_ATTRIBUTE_DATA attr; |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 // Like Move, this function is not transactional, so we just | 823 // Like Move, this function is not transactional, so we just |
844 // leave the copied bits behind if deleting from_path fails. | 824 // leave the copied bits behind if deleting from_path fails. |
845 // If to_path exists previously then we have already overwritten | 825 // If to_path exists previously then we have already overwritten |
846 // it by now, we don't get better off by deleting the new bits. | 826 // it by now, we don't get better off by deleting the new bits. |
847 } | 827 } |
848 return false; | 828 return false; |
849 } | 829 } |
850 | 830 |
851 } // namespace internal | 831 } // namespace internal |
852 } // namespace base | 832 } // namespace base |
OLD | NEW |