OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <windows.h> | 5 #include <windows.h> |
6 #include <setupapi.h> | 6 #include <setupapi.h> |
7 #include <winioctl.h> | 7 #include <winioctl.h> |
8 | 8 |
9 #include "chrome/utility/image_writer/error_messages.h" | 9 #include "chrome/utility/image_writer/error_messages.h" |
10 #include "chrome/utility/image_writer/image_writer.h" | 10 #include "chrome/utility/image_writer/image_writer.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 NULL); // Optional unused overlapped perameter. | 45 NULL); // Optional unused overlapped perameter. |
46 | 46 |
47 if (!status) { | 47 if (!status) { |
48 PLOG(ERROR) << "Storage property query failed"; | 48 PLOG(ERROR) << "Storage property query failed"; |
49 return false; | 49 return false; |
50 } | 50 } |
51 | 51 |
52 STORAGE_DEVICE_DESCRIPTOR* device_descriptor = | 52 STORAGE_DEVICE_DESCRIPTOR* device_descriptor = |
53 reinterpret_cast<STORAGE_DEVICE_DESCRIPTOR*>(output_buf.get()); | 53 reinterpret_cast<STORAGE_DEVICE_DESCRIPTOR*>(output_buf.get()); |
54 | 54 |
55 return device_descriptor->RemovableMedia == TRUE; | 55 return device_descriptor->RemovableMedia == TRUE || |
| 56 device_descriptor->BusType == BusTypeUsb; |
56 } | 57 } |
57 | 58 |
58 bool ImageWriter::OpenDevice() { | 59 bool ImageWriter::OpenDevice() { |
59 // Windows requires that device files be opened with FILE_FLAG_NO_BUFFERING | 60 // Windows requires that device files be opened with FILE_FLAG_NO_BUFFERING |
60 // and FILE_FLAG_WRITE_THROUGH. These two flags are not part of base::File. | 61 // and FILE_FLAG_WRITE_THROUGH. These two flags are not part of base::File. |
61 device_file_ = | 62 device_file_ = |
62 base::File(CreateFile(device_path_.value().c_str(), | 63 base::File(CreateFile(device_path_.value().c_str(), |
63 GENERIC_READ | GENERIC_WRITE, | 64 GENERIC_READ | GENERIC_WRITE, |
64 FILE_SHARE_READ | FILE_SHARE_WRITE, | 65 FILE_SHARE_READ | FILE_SHARE_WRITE, |
65 NULL, | 66 NULL, |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 190 |
190 if (volume_finder != INVALID_HANDLE_VALUE) { | 191 if (volume_finder != INVALID_HANDLE_VALUE) { |
191 FindVolumeClose(volume_finder); | 192 FindVolumeClose(volume_finder); |
192 } | 193 } |
193 | 194 |
194 if (success) | 195 if (success) |
195 continuation.Run(); | 196 continuation.Run(); |
196 } | 197 } |
197 | 198 |
198 } // namespace image_writer | 199 } // namespace image_writer |
OLD | NEW |