VirtualBox

Changeset 49039 in vbox for trunk/src/VBox/Storage


Ignore:
Timestamp:
Oct 10, 2013 6:27:32 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
89816
Message:

IPRT: Filename extension versus suffix cleanup, long overdue.

Location:
trunk/src/VBox/Storage
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Storage/Parallels.cpp

    r48743 r49039  
    205205    {
    206206        /* Check if the file has hdd as extension. It is a fixed size raw image then. */
    207         char *pszExtension = RTPathExt(pImage->pszFilename);
    208         if (strcmp(pszExtension, ".hdd"))
     207        char *pszSuffix = RTPathSuffix(pImage->pszFilename);
     208        if (strcmp(pszSuffix, ".hdd"))
    209209        {
    210210            rc = VERR_VD_PARALLELS_INVALID_HEADER;
     
    391391             */
    392392            uint64_t cbFile;
    393             char *pszExtension;
     393            char *pszSuffix;
    394394
    395395            rc = vdIfIoIntFileGetSize(pIfIo, pStorage, &cbFile);
     
    400400            }
    401401
    402             pszExtension = RTPathExt(pszFilename);
    403             if (!pszExtension || strcmp(pszExtension, ".hdd"))
     402            pszSuffix = RTPathSuffix(pszFilename);
     403            if (!pszSuffix || strcmp(pszSuffix, ".hdd"))
    404404                rc = VERR_VD_PARALLELS_INVALID_HEADER;
    405405            else
  • trunk/src/VBox/Storage/RAW.cpp

    r48743 r49039  
    349349    uint64_t cbFile;
    350350    int rc = VINF_SUCCESS;
    351     char *pszExtension = NULL;
     351    char *pszSuffix = NULL;
    352352
    353353    PVDINTERFACEIOINT pIfIo = VDIfIoIntGet(pVDIfsImage);
     
    361361    }
    362362
    363     pszExtension = RTPathExt(pszFilename);
     363    pszSuffix = RTPathSuffix(pszFilename);
    364364
    365365    /*
     
    375375    /* Try to guess the image type based on the extension. */
    376376    if (   RT_SUCCESS(rc)
    377         && pszExtension)
    378     {
    379         if (   !RTStrICmp(pszExtension, ".iso")
    380             || !RTStrICmp(pszExtension, ".cdr")) /* DVD images. */
     377        && pszSuffix)
     378    {
     379        if (   !RTStrICmp(pszSuffix, ".iso")
     380            || !RTStrICmp(pszSuffix, ".cdr")) /* DVD images. */
    381381        {
    382382            /* Note that there are ISO images smaller than 1 MB; it is impossible to distinguish
     
    392392                rc = VERR_VD_RAW_INVALID_HEADER;
    393393        }
    394         else if (   !RTStrICmp(pszExtension, ".img")
    395                  || !RTStrICmp(pszExtension, ".ima")
    396                  || !RTStrICmp(pszExtension, ".dsk")
    397                  || !RTStrICmp(pszExtension, ".flp")
    398                  || !RTStrICmp(pszExtension, ".vfd")) /* Floppy images */
     394        else if (   !RTStrICmp(pszSuffix, ".img")
     395                 || !RTStrICmp(pszSuffix, ".ima")
     396                 || !RTStrICmp(pszSuffix, ".dsk")
     397                 || !RTStrICmp(pszSuffix, ".flp")
     398                 || !RTStrICmp(pszSuffix, ".vfd")) /* Floppy images */
    399399        {
    400400            if (!(cbFile % 512) && cbFile <= RAW_MAX_FLOPPY_IMG_SIZE)
  • trunk/src/VBox/Storage/VMDK.cpp

    r48860 r49039  
    34293429        char pszPartition[1024];
    34303430        const char *pszBase = RTPathFilename(pImage->pszFilename);
    3431         const char *pszExt = RTPathExt(pszBase);
    3432         if (pszExt == NULL)
     3431        const char *pszSuff = RTPathSuffix(pszBase);
     3432        if (pszSuff == NULL)
    34333433            return vdIfError(pImage->pIfError, rc, RT_SRC_POS, N_("VMDK: invalid filename '%s'"), pImage->pszFilename);
    34343434        char *pszBaseBase = RTStrDup(pszBase);
    34353435        if (!pszBaseBase)
    34363436            return VERR_NO_MEMORY;
    3437         RTPathStripExt(pszBaseBase);
     3437        RTPathStripSuffix(pszBaseBase);
    34383438        RTStrPrintf(pszPartition, sizeof(pszPartition), "%s-pt%s",
    3439                     pszBaseBase, pszExt);
     3439                    pszBaseBase, pszSuff);
    34403440        RTStrFree(pszBaseBase);
    34413441
     
    36273627        else
    36283628        {
    3629             char *pszBasenameExt = RTPathExt(pszBasenameSubstr);
     3629            char *pszBasenameSuff = RTPathSuffix(pszBasenameSubstr);
    36303630            char *pszBasenameBase = RTStrDup(pszBasenameSubstr);
    3631             RTPathStripExt(pszBasenameBase);
     3631            RTPathStripSuffix(pszBasenameBase);
    36323632            char *pszTmp;
    36333633            size_t cbTmp;
     
    36363636                if (cExtents == 1)
    36373637                    RTStrAPrintf(&pszTmp, "%s-flat%s", pszBasenameBase,
    3638                                  pszBasenameExt);
     3638                                 pszBasenameSuff);
    36393639                else
    36403640                    RTStrAPrintf(&pszTmp, "%s-f%03d%s", pszBasenameBase,
    3641                                  i+1, pszBasenameExt);
     3641                                 i+1, pszBasenameSuff);
    36423642            }
    36433643            else
    36443644                RTStrAPrintf(&pszTmp, "%s-s%03d%s", pszBasenameBase, i+1,
    3645                              pszBasenameExt);
     3645                             pszBasenameSuff);
    36463646            RTStrFree(pszBasenameBase);
    36473647            if (!pszTmp)
     
    54915491    /* Prepare both old and new base names used for string replacement. */
    54925492    pszNewBaseName = RTStrDup(RTPathFilename(pszFilename));
    5493     RTPathStripExt(pszNewBaseName);
     5493    RTPathStripSuffix(pszNewBaseName);
    54945494    pszOldBaseName = RTStrDup(RTPathFilename(pImage->pszFilename));
    5495     RTPathStripExt(pszOldBaseName);
     5495    RTPathStripSuffix(pszOldBaseName);
    54965496    /* Prepare both old and new full names used for string replacement. */
    54975497    pszNewFullName = RTStrDup(pszFilename);
    5498     RTPathStripExt(pszNewFullName);
     5498    RTPathStripSuffix(pszNewFullName);
    54995499    pszOldFullName = RTStrDup(pImage->pszFilename);
    5500     RTPathStripExt(pszOldFullName);
     5500    RTPathStripSuffix(pszOldFullName);
    55015501
    55025502    /* --- Up to this point we have not done any damage yet. --- */
Note: See TracChangeset for help on using the changeset viewer.

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