VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Main/Forms/DeviceSelectionDialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Main/Forms/DeviceSelectionDialog.cpp')
-rw-r--r--src/Main/Forms/DeviceSelectionDialog.cpp57
1 files changed, 42 insertions, 15 deletions
diff --git a/src/Main/Forms/DeviceSelectionDialog.cpp b/src/Main/Forms/DeviceSelectionDialog.cpp
index 764edf3a..df4292c9 100644
--- a/src/Main/Forms/DeviceSelectionDialog.cpp
+++ b/src/Main/Forms/DeviceSelectionDialog.cpp
@@ -3,9 +3,9 @@
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2016 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2017 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
@@ -47,29 +47,56 @@ namespace VeraCrypt
DeviceList = Core->GetHostDevices();
foreach_ref (HostDevice &device, DeviceList)
{
- if (device.Size == 0)
- continue;
-
vector <wstring> fields (DeviceListCtrl->GetColumnCount());
-
+
if (DeviceListCtrl->GetItemCount() > 0)
Gui->AppendToListCtrl (DeviceListCtrl, fields);
+
+ // i.e. /dev/rdisk0 might have size = 0 in case open() fails because, for example on OSX,
+ // SIP is enabled on the machine ;
+ // This does not mean that it does not have partitions that have been successfully opened
+ // and have a size != 0 ;
+ // Therefore, we do not show the device ONLY if it does not have partitions with size != 0 ;
+ if (device.Size == 0)
+ {
+ bool bHasNonEmptyPartition = false;
+ foreach_ref (HostDevice &partition, device.Partitions)
+ {
+ if (partition.Size)
+ {
+ bHasNonEmptyPartition = true;
+ break;
+ }
+ }
+
+ if (!bHasNonEmptyPartition)
+ continue;
+ }
#ifdef TC_WINDOWS
- fields[ColumnDevice] = StringFormatter (L"{0} {1}:", _("Harddisk"), device.SystemNumber);
+ fields[ColumnDevice] = StringFormatter (L"{0} {1}:", LangString["HARDDISK"], device.SystemNumber);
fields[ColumnDrive] = device.MountPoint;
fields[ColumnName] = device.Name;
#else
fields[ColumnDevice] = wstring (device.Path) + L":";
fields[ColumnMountPoint] = device.MountPoint;
#endif
- fields[ColumnSize] = Gui->SizeToString (device.Size);
+ // If the size of the device is 0, we do not show the size to avoid confusing the user ;
+ if (device.Size)
+ fields[ColumnSize] = Gui->SizeToString (device.Size);
+ else
+ fields[ColumnSize] = L"";
Gui->AppendToListCtrl (DeviceListCtrl, fields, 0, &device);
foreach_ref (HostDevice &partition, device.Partitions)
{
+ // If a partition's size is 0, there is no need to show it in the list
+ // since this means it is not usable (i.e on OSX, because of SIP enabled in the machine) ;
+ if (!partition.Size)
+ continue;
+
fields[ColumnDevice] =
#ifndef TC_WINDOWS
wstring (L" ") +
#endif
@@ -92,33 +119,33 @@ namespace VeraCrypt
Fit();
Layout();
Center();
-
- StdButtonsOK->Disable();
- StdButtonsOK->SetDefault();
+ OKButton->Disable();
+ OKButton->SetDefault();
}
void DeviceSelectionDialog::OnListItemActivated (wxListEvent& event)
{
- if (StdButtonsOK->IsEnabled())
+ if (OKButton->IsEnabled())
EndModal (wxID_OK);
}
void DeviceSelectionDialog::OnListItemDeselected (wxListEvent& event)
{
if (DeviceListCtrl->GetSelectedItemCount() == 0)
- StdButtonsOK->Disable();
+ OKButton->Disable();
}
void DeviceSelectionDialog::OnListItemSelected (wxListEvent& event)
{
HostDevice *device = (HostDevice *) (event.GetItem().GetData());
- if (device)
+ // If a device's size is 0, we do not enable the 'OK' button since it is not usable
+ if (device && device->Size)
{
SelectedDevice = *device;
- StdButtonsOK->Enable();
+ OKButton->Enable();
}
else
- StdButtonsOK->Disable();
+ OKButton->Disable();
}
}