Chromium Code Reviews| 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..96c3528eb044905494903d1945949049f9f665fb 100644 |
| --- a/base/files/file_util_win.cc |
| +++ b/base/files/file_util_win.cc |
| @@ -559,6 +559,28 @@ bool NormalizeToNativeFilePath(const FilePath& path, FilePath* nt_path) { |
| return success; |
| } |
| +bool IsOnNetworkDrive(const base::FilePath& path) { |
| + win::ScopedHandle handle( |
| + ::CreateFileW(path.value().c_str(), |
| + 0, |
| + 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
|
| + NULL, |
| + OPEN_EXISTING, |
| + FILE_FLAG_BACKUP_SEMANTICS, // Needed to open directory. |
| + NULL)); |
| + |
| + FILE_REMOTE_PROTOCOL_INFO remote_proto_info = {0}; |
| + |
| + // If able to get network information, then the file is on a network. |
| + if (::GetFileInformationByHandleEx(handle.Get(), |
|
Lei Zhang
2016/04/15 21:16:36
Just return !!::GetFoo(...) ?
Will Harris
2016/04/15 21:30:31
Acknowledged.
|
| + FileRemoteProtocolInfo, &remote_proto_info, |
| + sizeof(remote_proto_info))) { |
| + 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.
|
| + } |
| + |
| + return false; |
| +} |
| + |
| // 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) { |