VirtualBox

Ignore:
Timestamp:
Oct 30, 2009 11:11:45 AM (15 years ago)
Author:
vboxsync
Message:

VBoxManage createhd: append the proper extension to the filename if it doesn't contain an extension

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp

    r23973 r24184  
    254254
    255255    /* check the outcome */
    256     if (!filename || (sizeMB == 0))
     256    if (   !filename
     257        || sizeMB == 0)
    257258        return errorSyntax(USAGE_CREATEHD, "Parameters --filename and --size are required");
     259
     260    /* check for filename extension */
     261    Utf8Str strName(filename);
     262    if (!RTPathHaveExt(strName.c_str()))
     263    {
     264        Utf8Str strFormat(format);
     265        if (strFormat.compare("vmdk", iprt::MiniString::CaseInsensitive) == 0)
     266            strName.append(".vmdk");
     267        else if (strFormat.compare("vhd", iprt::MiniString::CaseInsensitive) == 0)
     268            strName.append(".vhd");
     269        else
     270            strName.append(".vdi");
     271        filename = Bstr(strName);
     272    }
    258273
    259274    ComPtr<IMedium> hardDisk;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette