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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/files/file_util_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_util_win.cc
diff --git a/base/files/file_util_win.cc b/base/files/file_util_win.cc
index d70454df3836a7067f71eecf5a0ae8673376f474..ddb9c2806a75bae7ed7fc03033693335fe1d6020 100644
--- a/base/files/file_util_win.cc
+++ b/base/files/file_util_win.cc
@@ -559,6 +559,26 @@ bool NormalizeToNativeFilePath(const FilePath& path, FilePath* nt_path) {
return success;
}
+bool IsOnNetworkDrive(const base::FilePath& path) {
+ win::ScopedHandle handle(
+ ::CreateFileW(path.value().c_str(),
+ GENERIC_READ,
+ kFileShareAll,
+ NULL,
+ OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS, // Needed to open directory.
+ NULL));
+
+ if (!handle.IsValid())
+ return false;
+
+ // If able to get network information, then the file is on a network.
+ FILE_REMOTE_PROTOCOL_INFO remote_proto_info = {0};
+ return !!::GetFileInformationByHandleEx(handle.Get(), FileRemoteProtocolInfo,
+ &remote_proto_info,
+ sizeof(remote_proto_info));
+}
+
// TODO(rkc): Work out if we want to handle NTFS junctions here or not, handle
// them if we do decide to.
bool IsLink(const FilePath& file_path) {
« 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