Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1251)

Side by Side Diff: base/files/file_util_win.cc

Issue 1917893004: Merge M51: Add base::IsOnNetworkDrive. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/files/file_util_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
562 // TODO(rkc): Work out if we want to handle NTFS junctions here or not, handle 582 // TODO(rkc): Work out if we want to handle NTFS junctions here or not, handle
563 // them if we do decide to. 583 // them if we do decide to.
564 bool IsLink(const FilePath& file_path) { 584 bool IsLink(const FilePath& file_path) {
565 return false; 585 return false;
566 } 586 }
567 587
568 bool GetFileInfo(const FilePath& file_path, File::Info* results) { 588 bool GetFileInfo(const FilePath& file_path, File::Info* results) {
569 ThreadRestrictions::AssertIOAllowed(); 589 ThreadRestrictions::AssertIOAllowed();
570 590
571 WIN32_FILE_ATTRIBUTE_DATA attr; 591 WIN32_FILE_ATTRIBUTE_DATA attr;
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 // Like Move, this function is not transactional, so we just 843 // Like Move, this function is not transactional, so we just
824 // leave the copied bits behind if deleting from_path fails. 844 // leave the copied bits behind if deleting from_path fails.
825 // If to_path exists previously then we have already overwritten 845 // 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. 846 // it by now, we don't get better off by deleting the new bits.
827 } 847 }
828 return false; 848 return false;
829 } 849 }
830 850
831 } // namespace internal 851 } // namespace internal
832 } // namespace base 852 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_util_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698