VirtualBox

Changeset 73586 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Aug 9, 2018 1:34:57 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6596 Adding a size check for FAT file systems in create new hdd wizards

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r73198 r73586  
    16881688}
    16891689
     1690void UIMessageCenter::cannotCreateHardDiskStorageInFAT(const QString &strLocation, QWidget *pParent /* = 0 */) const
     1691{
     1692    error(pParent, MessageType_Error,
     1693          tr("Failed to create the hard disk storage <nobr><b>%1</b>.</nobr> FAT file systems has 4GB (minus some overhead) size limit")
     1694          .arg(strLocation), QString());
     1695}
     1696
    16901697void UIMessageCenter::cannotCreateMediumStorage(const CVirtualBox &comVBox, const QString &strLocation, QWidget *pParent /* = 0 */) const
    16911698{
     
    28892896    return iResultCode;
    28902897}
    2891 
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r73198 r73586  
    370370    void cannotCreateHardDiskStorage(const CMedium &medium, const QString &strLocation, QWidget *pParent = 0) const;
    371371    void cannotCreateHardDiskStorage(const CProgress &progress, const QString &strLocation, QWidget *pParent = 0) const;
     372    void cannotCreateHardDiskStorageInFAT(const QString &strLocation, QWidget *pParent = 0) const;
    372373    void cannotCreateMediumStorage(const CVirtualBox &comVBox, const QString &strLocation, QWidget *pParent = 0) const;
    373374    void cannotCreateMediumStorage(const CMedium &comMedium, const QString &strLocation, QWidget *pParent = 0) const;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVD.cpp

    r72696 r73586  
    151151    UIWizard::prepare();
    152152}
    153 
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic3.cpp

    r71027 r73586  
    4848#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    4949
     50/* Other VBox includes: */
     51#include <iprt/path.h>
    5052
    5153UIWizardNewVDPage3::UIWizardNewVDPage3(const QString &strDefaultName, const QString &strDefaultPath)
     
    262264
    263265    if (fResult)
     266        fResult = checkFATSizeLimitation();
     267
     268    if (!fResult)
     269        msgCenter().cannotCreateHardDiskStorageInFAT(strMediumPath, this);
     270    else
    264271    {
    265272        /* Lock finish button: */
     
    268275        /* Try to create virtual hard drive file: */
    269276        fResult = qobject_cast<UIWizardNewVD*>(wizard())->createVirtualDisk();
    270 
    271         /* Unlock finish button: */
     277       /* Unlock finish button: */
    272278        endProcessing();
    273279    }
     
    277283}
    278284
     285bool UIWizardNewVDPage3::checkFATSizeLimitation()
     286{
     287    QString strMediumPath(mediumPath());
     288    RTFSTYPE enmType;
     289    int rc = RTFsQueryType(QFileInfo(strMediumPath).absolutePath().toLatin1().constData(), &enmType);
     290    if (RT_SUCCESS(rc))
     291    {
     292        if (enmType == RTFSTYPE_FAT)
     293        {
     294            /* Limit the medium size to 4GB. minus 128 MB for file overhead: */
     295            qulonglong fatLimit = 4 * pow(2,30) - 128 * pow(2, 20);
     296            if (mediumSize() >= fatLimit)
     297                return false;
     298        }
     299    }
     300    return true;
     301}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic3.h

    r72021 r73586  
    4545    static QString absoluteFilePath(const QString &strFileName, const QString &strDefaultPath);
    4646    static QString defaultExtension(const CMediumFormat &mediumFormatRef);
     47
     48    /* Checks if the medium file is bigger than what is allowed in FAT file systems. */
     49    bool checkFATSizeLimitation();
    4750
    4851    /* Stuff for 'mediumPath' field: */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageExpert.cpp

    r72821 r73586  
    269269        msgCenter().cannotOverwriteHardDiskStorage(strMediumPath, this);
    270270
     271    if (fResult)
     272        fResult = checkFATSizeLimitation();
     273
     274    if (!fResult)
     275        msgCenter().cannotCreateHardDiskStorageInFAT(strMediumPath, this);
     276
    271277    /* Try to create virtual-disk: */
    272278    if (fResult)
     
    279285    return fResult;
    280286}
    281 
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