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 0, | |
566 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, | |
Lei Zhang
2016/04/15 21:16:36
Do you need write and delete permissions?
Will Harris
2016/04/15 21:30:31
These aren't file reading permissions these are fi
| |
567 NULL, | |
568 OPEN_EXISTING, | |
569 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open directory. | |
570 NULL)); | |
571 | |
572 FILE_REMOTE_PROTOCOL_INFO remote_proto_info = {0}; | |
573 | |
574 // If able to get network information, then the file is on a network. | |
575 if (::GetFileInformationByHandleEx(handle.Get(), | |
Lei Zhang
2016/04/15 21:16:36
Just return !!::GetFoo(...) ?
Will Harris
2016/04/15 21:30:31
Acknowledged.
| |
576 FileRemoteProtocolInfo, &remote_proto_info, | |
577 sizeof(remote_proto_info))) { | |
578 return true; | |
cpu_(ooo_6.6-7.5)
2016/04/15 20:55:33
seems reasonable... but what if the file does not
Will Harris
2016/04/15 21:15:06
files that don't exist are not on a network drive.
| |
579 } | |
580 | |
581 return false; | |
582 } | |
583 | |
562 // TODO(rkc): Work out if we want to handle NTFS junctions here or not, handle | 584 // TODO(rkc): Work out if we want to handle NTFS junctions here or not, handle |
563 // them if we do decide to. | 585 // them if we do decide to. |
564 bool IsLink(const FilePath& file_path) { | 586 bool IsLink(const FilePath& file_path) { |
565 return false; | 587 return false; |
566 } | 588 } |
567 | 589 |
568 bool GetFileInfo(const FilePath& file_path, File::Info* results) { | 590 bool GetFileInfo(const FilePath& file_path, File::Info* results) { |
569 ThreadRestrictions::AssertIOAllowed(); | 591 ThreadRestrictions::AssertIOAllowed(); |
570 | 592 |
571 WIN32_FILE_ATTRIBUTE_DATA attr; | 593 WIN32_FILE_ATTRIBUTE_DATA attr; |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
823 // Like Move, this function is not transactional, so we just | 845 // Like Move, this function is not transactional, so we just |
824 // leave the copied bits behind if deleting from_path fails. | 846 // leave the copied bits behind if deleting from_path fails. |
825 // If to_path exists previously then we have already overwritten | 847 // If to_path exists previously then we have already overwritten |
826 // it by now, we don't get better off by deleting the new bits. | 848 // it by now, we don't get better off by deleting the new bits. |
827 } | 849 } |
828 return false; | 850 return false; |
829 } | 851 } |
830 | 852 |
831 } // namespace internal | 853 } // namespace internal |
832 } // namespace base | 854 } // namespace base |
OLD | NEW |