VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Main/Forms/VolumeSizeWizardPage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Main/Forms/VolumeSizeWizardPage.cpp')
-rw-r--r--src/Main/Forms/VolumeSizeWizardPage.cpp58
1 files changed, 47 insertions, 11 deletions
diff --git a/src/Main/Forms/VolumeSizeWizardPage.cpp b/src/Main/Forms/VolumeSizeWizardPage.cpp
index 47d73983..61427ea5 100644
--- a/src/Main/Forms/VolumeSizeWizardPage.cpp
+++ b/src/Main/Forms/VolumeSizeWizardPage.cpp
@@ -24,9 +24,10 @@ namespace VeraCrypt
SectorSize (sectorSize),
AvailableDiskSpace (0)
{
- VolumeSizePrefixChoice->Append (LangString["KB"], reinterpret_cast <void *> (1024));
- VolumeSizePrefixChoice->Append (LangString["MB"], reinterpret_cast <void *> (1024 * 1024));
- VolumeSizePrefixChoice->Append (LangString["GB"], reinterpret_cast <void *> (1024 * 1024 * 1024));
+ VolumeSizePrefixChoice->Append (LangString["KB"], reinterpret_cast <void *> (1));
+ VolumeSizePrefixChoice->Append (LangString["MB"], reinterpret_cast <void *> (2));
+ VolumeSizePrefixChoice->Append (LangString["GB"], reinterpret_cast <void *> (3));
+ VolumeSizePrefixChoice->Append (LangString["TB"], reinterpret_cast <void *> (4));
VolumeSizePrefixChoice->Select (Prefix::MB);
wxLongLong diskSpace = 0;
@@ -34,6 +35,7 @@ namespace VeraCrypt
{
VolumeSizeTextCtrl->Disable();
VolumeSizeTextCtrl->SetValue (L"");
+ UseAllFreeSpaceCheckBox->Disable();
}
else
{
@@ -74,13 +76,25 @@ namespace VeraCrypt
uint64 VolumeSizeWizardPage::GetVolumeSize () const
{
uint64 prefixMult = 1;
- int selection = VolumeSizePrefixChoice->GetSelection();
- if (selection == wxNOT_FOUND)
- return 0;
-
- prefixMult = reinterpret_cast <uint64> (VolumeSizePrefixChoice->GetClientData (selection));
+ uint64 val;
+ if (UseAllFreeSpaceCheckBox->IsChecked ())
+ {
+ val = AvailableDiskSpace;
+ }
+ else
+ {
+ int selection = VolumeSizePrefixChoice->GetSelection();
+ if (selection == wxNOT_FOUND)
+ return 0;
- uint64 val = StringConverter::ToUInt64 (wstring (VolumeSizeTextCtrl->GetValue()));
+ uint64 counter = reinterpret_cast <uint64> (VolumeSizePrefixChoice->GetClientData (selection));
+ while (counter)
+ {
+ prefixMult *= 1024;
+ counter--;
+ }
+ val = StringConverter::ToUInt64 (wstring(VolumeSizeTextCtrl->GetValue()));
+ }
if (val <= 0x7fffFFFFffffFFFFull / prefixMult)
{
val *= prefixMult;
@@ -98,7 +112,7 @@ namespace VeraCrypt
bool VolumeSizeWizardPage::IsValid ()
{
- if (!VolumeSizeTextCtrl->GetValue().empty() && Validate())
+ if ((!VolumeSizeTextCtrl->GetValue().empty() || UseAllFreeSpaceCheckBox->IsChecked ()) && Validate())
{
try
{
@@ -126,7 +140,12 @@ namespace VeraCrypt
return;
}
- if (size % (1024 * 1024 * 1024) == 0)
+ if (size % (1024ULL * 1024ULL * 1024ULL * 1024ULL) == 0)
+ {
+ size /= 1024ULL * 1024ULL * 1024ULL * 1024ULL;
+ VolumeSizePrefixChoice->Select (Prefix::TB);
+ }
+ else if (size % (1024 * 1024 * 1024) == 0)
{
size /= 1024 * 1024 * 1024;
VolumeSizePrefixChoice->Select (Prefix::GB);
@@ -144,4 +163,21 @@ namespace VeraCrypt
VolumeSizeTextCtrl->SetValue (StringConverter::FromNumber (size));
}
+
+ void VolumeSizeWizardPage::OnUseAllFreeSpaceCheckBoxClick( wxCommandEvent& event )
+ {
+ if (UseAllFreeSpaceCheckBox->IsChecked ())
+ {
+ VolumeSizePrefixChoice->Select (Prefix::MB);
+ VolumeSizeTextCtrl->SetValue (L"");
+ VolumeSizePrefixChoice->Disable();
+ VolumeSizeTextCtrl->Disable();
+ }
+ else
+ {
+ VolumeSizePrefixChoice->Enable();
+ VolumeSizeTextCtrl->SetValue (L"");
+ VolumeSizeTextCtrl->Enable();
+ }
+ }
}