VirtualBox

Changeset 49039 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Oct 10, 2013 6:27:32 PM (11 years ago)
Author:
vboxsync
Message:

IPRT: Filename extension versus suffix cleanup, long overdue.

Location:
trunk/src/VBox
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp

    r48775 r49039  
    17421742                    if (pszLogFile)
    17431743                    {
    1744                         char *pszLogExt = NULL;
    1745                         if (RTPathHasExt(pszLogFile))
    1746                             pszLogExt = RTStrDup(RTPathExt(pszLogFile));
    1747                         RTPathStripExt(pszLogFile);
    1748                         char *pszLogSuffix;
     1744                        char *pszLogSuff = NULL;
     1745                        if (RTPathHasSuffix(pszLogFile))
     1746                            pszLogSuff = RTStrDup(RTPathSuffix(pszLogFile));
     1747                        RTPathStripSuffix(pszLogFile);
     1748                        char *pszLogNewSuffix;
    17491749#ifndef DEBUG
    1750                         if (RTStrAPrintf(&pszLogSuffix, "-%RU32-%s",
     1750                        if (RTStrAPrintf(&pszLogNewSuffix, "-%RU32-%s",
    17511751                                         pSessionStartupInfo->uSessionID,
    17521752                                         pSessionStartupInfo->szUser) < 0)
     
    17551755                        }
    17561756#else
    1757                         if (RTStrAPrintf(&pszLogSuffix, "-%RU32-%RU32-%s",
     1757                        if (RTStrAPrintf(&pszLogNewSuffix, "-%RU32-%RU32-%s",
    17581758                                         pSessionStartupInfo->uSessionID,
    17591759                                         s_uCtrlSessionThread,
     
    17651765                        else
    17661766                        {
    1767                             rc2 = RTStrAAppend(&pszLogFile, pszLogSuffix);
    1768                             if (RT_SUCCESS(rc2) && pszLogExt)
    1769                                 rc2 = RTStrAAppend(&pszLogFile, pszLogExt);
     1767                            rc2 = RTStrAAppend(&pszLogFile, pszLogNewSuffix);
     1768                            if (RT_SUCCESS(rc2) && pszLogSuff)
     1769                                rc2 = RTStrAAppend(&pszLogFile, pszLogSuff);
    17701770                            if (RT_SUCCESS(rc2))
    17711771                            {
     
    17761776                                }
    17771777                            }
    1778                             RTStrFree(pszLogSuffix);
     1778                            RTStrFree(pszLogNewSuffix);
    17791779                        }
    17801780                        if (RT_FAILURE(rc2))
    17811781                            VBoxServiceError("Error building session logfile string for session %RU32 (user %s), rc=%Rrc\n",
    17821782                                             pSessionStartupInfo->uSessionID, pSessionStartupInfo->szUser, rc2);
    1783                         if (pszLogExt)
    1784                             RTStrFree(pszLogExt);
     1783                        if (pszLogSuff)
     1784                            RTStrFree(pszLogSuff);
    17851785                        RTStrFree(pszLogFile);
    17861786                    }
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp

    r47906 r49039  
    323323        if (!format || !*format)
    324324        {
    325             const char *pszExt = RTPathExt(filename);
     325            const char *pszExt = RTPathSuffix(filename);
    326326            /* Skip over . if there is an extension. */
    327327            if (pszExt)
     
    356356    /** @todo use IMediumFormat to cover all extensions generically */
    357357    Utf8Str strName(filename);
    358     if (!RTPathHaveExt(strName.c_str()))
     358    if (!RTPathHasSuffix(strName.c_str()))
    359359    {
    360360        Utf8Str strFormat(format);
  • trunk/src/VBox/HostDrivers/Support/SUPLib.cpp

    r46326 r49039  
    21992199     * Add the default extension if it's missing.
    22002200     */
    2201     if (!RTPathHaveExt(pszFilename))
     2201    if (!RTPathHasSuffix(pszFilename))
    22022202    {
    22032203        const char *pszSuff = RTLdrGetSuff();
     
    22392239    const char *pszExt = "";
    22402240    size_t cchExt = 0;
    2241     if (!RTPathHaveExt(pszFilename))
     2241    if (!RTPathHasSuffix(pszFilename))
    22422242    {
    22432243        pszExt = RTLdrGetSuff();
     
    26592659
    26602660    memcpy(Req.u.In.szName, pszModule, cchModule + 1);
    2661     if (!RTPathHasExt(Req.u.In.szName))
     2661    if (!RTPathHasSuffix(Req.u.In.szName))
    26622662    {
    26632663        /* Add the default suffix if none is given. */
  • trunk/src/VBox/Installer/linux/install_service/generate_service_file.cpp

    r44529 r49039  
    585585            else
    586586            {
    587                 const char *pcszFileName =
    588                     RTPathFilename(pParameters->pcszCommand);
    589                 const char *pcszExtension =
    590                     RTPathExt(pParameters->pcszCommand);
     587                const char *pcszFileName = RTPathFilename(pParameters->pcszCommand);
     588                const char *pcszSuffix   = RTPathSuffix(pParameters->pcszCommand);
    591589                char *pszName = RTStrDupN(pcszFileName,
    592                                             pcszExtension
    593                                           ? pcszExtension - pcszFileName
     590                                            pcszSuffix
     591                                          ? pcszSuffix - pcszFileName
    594592                                          : RTPATH_MAX);
    595593                bool fRc;
  • trunk/src/VBox/Installer/win/Stub/VBoxStub.cpp

    r45332 r49039  
    626626
    627627    RTEXITCODE rcExit;
    628     const char *pszExt = RTPathExt(szPkgFile);
    629     if (RTStrICmp(pszExt, ".msi") == 0)
     628    const char *pszSuff = RTPathSuffix(szPkgFile);
     629    if (RTStrICmp(pszSuff, ".msi") == 0)
    630630        rcExit = ProcessMsiPackage(szPkgFile, pszMsiArgs, fLogging);
    631     else if (RTStrICmp(pszExt, ".cab") == 0)
     631    else if (RTStrICmp(pszSuff, ".cab") == 0)
    632632        rcExit = RTEXITCODE_SUCCESS; /* Ignore .cab files, they're generally referenced by other files. */
    633633    else
  • trunk/src/VBox/Main/glue/string.cpp

    r45927 r49039  
    135135}
    136136
    137 Utf8Str& Utf8Str::stripExt()
    138 {
    139     if (length())
    140     {
    141         RTPathStripExt(m_psz);
     137Utf8Str& Utf8Str::stripSuffix()
     138{
     139    if (length())
     140    {
     141        RTPathStripSuffix(m_psz);
    142142        jolt();
    143143    }
  • trunk/src/VBox/Main/src-client/DisplayImpl.cpp

    r47905 r49039  
    27392739    {
    27402740        char *pszAbsPath = RTPathAbsDup(com::Utf8Str(strFile).c_str());
    2741         char *pszExt = RTPathExt(pszAbsPath);
    2742         if (pszExt)
    2743             pszExt = RTStrDup(pszExt);
    2744         RTPathStripExt(pszAbsPath);
     2741        char *pszSuff = RTPathSuffix(pszAbsPath);
     2742        if (pszSuff)
     2743            pszSuff = RTStrDup(pszSuff);
     2744        RTPathStripSuffix(pszAbsPath);
    27452745        if (!pszAbsPath)
    27462746            rc = VERR_INVALID_PARAMETER;
    2747         if (!pszExt)
    2748             pszExt = RTStrDup(".webm");
     2747        if (!pszSuff)
     2748            pszSuff = RTStrDup(".webm");
    27492749        char *pszName = NULL;
    27502750        if (RT_SUCCESS(rc))
    27512751        {
    27522752            if (mcMonitors > 1)
    2753                 rc = RTStrAPrintf(&pszName, "%s-%u%s", pszAbsPath, uScreen+1, pszExt);
     2753                rc = RTStrAPrintf(&pszName, "%s-%u%s", pszAbsPath, uScreen+1, pszSuff);
    27542754            else
    2755                 rc = RTStrAPrintf(&pszName, "%s%s", pszAbsPath, pszExt);
     2755                rc = RTStrAPrintf(&pszName, "%s%s", pszAbsPath, pszSuff);
    27562756        }
    27572757        if (RT_SUCCESS(rc))
     
    27682768                                      pszAbsPath, time.i32Year, time.u8Month, time.u8MonthDay,
    27692769                                      time.u8Hour, time.u8Minute, time.u8Second, time.u32Nanosecond,
    2770                                       uScreen+1, pszExt);
     2770                                      uScreen+1, pszSuff);
    27712771                else
    27722772                    rc = RTStrAPrintf(&pszName, "%s-%04d-%02u-%02uT%02u-%02u-%02u-%09uZ%s",
    27732773                                      pszAbsPath, time.i32Year, time.u8Month, time.u8MonthDay,
    27742774                                      time.u8Hour, time.u8Minute, time.u8Second, time.u32Nanosecond,
    2775                                       pszExt);
     2775                                      pszSuff);
    27762776                if (RT_SUCCESS(rc))
    27772777                    rc = VideoRecStrmInit(mpVideoRecCtx, uScreen,
     
    27862786            LogRel(("Failed to initialize video recording context #%u (%Rrc)!\n", uScreen, rc));
    27872787        RTStrFree(pszName);
    2788         RTStrFree(pszExt);
     2788        RTStrFree(pszSuff);
    27892789        RTStrFree(pszAbsPath);
    27902790    }
  • trunk/src/VBox/Main/src-server/ApplianceImpl.cpp

    r48685 r49039  
    788788        RTPathStripFilename(tmpDir);;
    789789        char *tmpFile = RTStrDup(RTPathFilename(aName.c_str()));
    790         RTPathStripExt(tmpFile);
    791         const char *tmpExt = RTPathExt(aName.c_str());
    792         RTStrAPrintf(&tmpName, "%s%c%s_%d%s", tmpDir, RTPATH_DELIMITER, tmpFile, i, tmpExt);
     790        RTPathStripSuffix(tmpFile);
     791        const char *pszTmpSuff = RTPathSuffix(aName.c_str());
     792        RTStrAPrintf(&tmpName, "%s%c%s_%d%s", tmpDir, RTPATH_DELIMITER, tmpFile, i, pszTmpSuff);
    793793        RTStrFree(tmpFile);
    794794        RTStrFree(tmpDir);
  • trunk/src/VBox/Main/src-server/ApplianceImplExport.cpp

    r49038 r49039  
    352352                if (FAILED(rc)) throw rc;
    353353
    354                 Utf8Str strTargetName = Utf8Str(locInfo.strPath).stripPath().stripExt();
     354                Utf8Str strTargetName = Utf8Str(locInfo.strPath).stripPath().stripSuffix();
    355355                strTargetVmdkName = Utf8StrFmt("%s-disk%d.vmdk", strTargetName.c_str(), ++pAppliance->m->cDisks);
    356356                if (strTargetVmdkName.length() > RTTAR_NAME_MAX)
     
    388388                if (FAILED(rc)) throw rc;
    389389
    390                 Utf8Str strTargetName = Utf8Str(locInfo.strPath).stripPath().stripExt();
     390                Utf8Str strTargetName = Utf8Str(locInfo.strPath).stripPath().stripSuffix();
    391391                strTargetVmdkName = Utf8StrFmt("%s-disk%d.iso", strTargetName.c_str(), ++pAppliance->m->cDisks);
    392392                if (strTargetVmdkName.length() > RTTAR_NAME_MAX)
     
    20152015            Utf8Str strOvaFile = pTask->locInfo.strPath;
    20162016            /* Extract the path */
    2017             Utf8Str strOvfFile = strOvaFile.stripExt().append(".ovf");
     2017            Utf8Str strOvfFile = strOvaFile.stripSuffix().append(".ovf");
    20182018            // Create a memory buffer containing the XML. */
    20192019            void *pvBuf = 0;
     
    22352235        {
    22362236            // Create & write the manifest file
    2237             Utf8Str strMfFilePath = Utf8Str(pTask->locInfo.strPath).stripExt().append(".mf");
     2237            Utf8Str strMfFilePath = Utf8Str(pTask->locInfo.strPath).stripSuffix().append(".mf");
    22382238            Utf8Str strMfFileName = Utf8Str(strMfFilePath).stripPath();
    22392239            pTask->pProgress->SetNextOperation(BstrFmt(tr("Creating manifest file '%s'"), strMfFileName.c_str()).raw(),
     
    23712371        if (m->fManifest)
    23722372        {
    2373             Utf8Str strMfFile = Utf8Str(strTmpOvf).stripExt().append(".mf");
     2373            Utf8Str strMfFile = Utf8Str(strTmpOvf).stripSuffix().append(".mf");
    23742374            filesList.push_back(pair<Utf8Str, ULONG>(strMfFile , m->ulWeightForXmlOperation)); /* Use 1% of the total for the manifest file upload */
    23752375        }
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r49038 r49039  
    641641                        /* Figure out from extension which format the image of disk has. */
    642642                        {
    643                             char *pszExt = RTPathExt(di.strHref.c_str());
     643                            char *pszExt = RTPathSuffix(di.strHref.c_str());
     644                            if (pszExt)
     645                                pszExt++;
    644646                            /* Get the system properties. */
    645647                            SystemProperties *pSysProps = mVirtualBox->getSystemProperties();
    646                             ComObjPtr<MediumFormat> trgFormat = pSysProps->mediumFormatFromExtension(&pszExt[1]);
     648                            ComObjPtr<MediumFormat> trgFormat = pSysProps->mediumFormatFromExtension(pszExt);
    647649                            if (trgFormat.isNull())
    648650                            {
     
    955957            }
    956958
    957             Utf8Str strMfFile = Utf8Str(pTask->locInfo.strPath).stripExt().append(".mf");
     959            Utf8Str strMfFile = Utf8Str(pTask->locInfo.strPath).stripSuffix().append(".mf");
    958960
    959961            SHASTORAGE storage;
     
    11011103            }
    11021104
    1103             Utf8Str extension(RTPathExt(pszFilename));
    1104 
    1105             if (!extension.endsWith(".ovf",Utf8Str::CaseInsensitive))
     1105            Utf8Str suffix(RTPathSuffix(pszFilename));
     1106
     1107            if (!suffix.endsWith(".ovf",Utf8Str::CaseInsensitive))
    11061108            {
    11071109                vrc = VERR_FILE_NOT_FOUND;
     
    15231525            throw setError(E_OUTOFMEMORY);
    15241526
    1525         Utf8Str strMfFile = Utf8Str(pTask->locInfo.strPath).stripExt().append(".mf");
     1527        Utf8Str strMfFile = Utf8Str(pTask->locInfo.strPath).stripSuffix().append(".mf");
    15261528
    15271529        SHASTORAGE storage;
     
    15731575            Utf8Str manifestShaDigest = storage.strDigest;
    15741576
    1575             Utf8Str strCertFile = Utf8Str(pTask->locInfo.strPath).stripExt().append(".cert");
     1577            Utf8Str strCertFile = Utf8Str(pTask->locInfo.strPath).stripSuffix().append(".cert");
    15761578            if (RTFileExists(strCertFile.c_str()))
    15771579            {
     
    16851687        size_t cbMfSize = 0;
    16861688        size_t cbCertSize = 0;
    1687         Utf8Str strMfFile = (Utf8Str(pszFilename)).stripExt().append(".mf");
    1688         Utf8Str strCertFile = (Utf8Str(pszFilename)).stripExt().append(".cert");
     1689        Utf8Str strMfFile = (Utf8Str(pszFilename)).stripSuffix().append(".mf");
     1690        Utf8Str strCertFile = (Utf8Str(pszFilename)).stripSuffix().append(".cert");
    16891691
    16901692        /* Skip the OVF file, cause this was read in IAppliance::Read already. */
     
    22992301                Utf8Str strTempTargetFilename(*strTargetPath);
    23002302                strTempTargetFilename = strTempTargetFilename.stripPath();
    2301                 strTempTargetFilename = strTempTargetFilename.stripExt();
     2303                strTempTargetFilename = strTempTargetFilename.stripSuffix();
    23022304                Utf8Str vdf = typeOfVirtualDiskFormatFromURI(di.strFormat);
    23032305
     
    23372339            Utf8Str strTrgFormat = "VMDK";
    23382340            ULONG lCabs = 0;
    2339             char *pszExt = NULL;
    2340 
    2341             if (RTPathHaveExt(strTargetPath->c_str()))
    2342             {
    2343                 pszExt = RTPathExt(strTargetPath->c_str());
     2341
     2342            if (RTPathHasSuffix(strTargetPath->c_str()))
     2343            {
     2344                const char *pszSuff = RTPathSuffix(strTargetPath->c_str());
    23442345                /* Figure out which format the user like to have. Default is VMDK. */
    2345                 ComObjPtr<MediumFormat> trgFormat = pSysProps->mediumFormatFromExtension(&pszExt[1]);
     2346                ComObjPtr<MediumFormat> trgFormat = pSysProps->mediumFormatFromExtension(&pszSuff[1]);
    23462347                if (trgFormat.isNull())
    23472348                    throw setError(VBOX_E_NOT_SUPPORTED,
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r48983 r49039  
    79117911
    79127912    strFile = mData->m_strConfigFileFull;       // path/to/machinesfolder/vmname/vmname.vbox
    7913     strFile.stripExt();                         // path/to/machinesfolder/vmname/vmname
     7913    strFile.stripSuffix();                      // path/to/machinesfolder/vmname/vmname
    79147914    strFile.append(".webm");                    // path/to/machinesfolder/vmname/vmname.webm
    79157915}
     
    1197411974    Utf8Str strConfigFileOnly(mData->m_strConfigFileFull);  // path/to/machinesfolder/vmname/vmname.vbox
    1197511975    strConfigFileOnly.stripPath()                           // vmname.vbox
    11976                      .stripExt();                           // vmname
     11976                     .stripSuffix();                        // vmname
    1197711977    /** @todo hack, make somehow use of ComposeMachineFilename */
    1197811978    if (mUserData->s.fDirectoryIncludesUUID)
  • trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp

    r48955 r49039  
    11341134                            if (!mt.strBaseName.isEmpty())
    11351135                                strSrcTest = mt.strBaseName;
    1136                             strSrcTest.stripExt();
     1136                            strSrcTest.stripSuffix();
    11371137                            /* If the old disk name was in {uuid} format we also
    11381138                             * want the new name in this format, but with the
     
    11421142                             * template: "new name-disk1.vdi". */
    11431143                            if (strSrcTest == strOldVMName)
    1144                                 strNewName = Utf8StrFmt("%s%s", trgMCF.machineUserData.strName.c_str(), RTPathExt(Utf8Str(bstrSrcName).c_str()));
     1144                                strNewName = Utf8StrFmt("%s%s", trgMCF.machineUserData.strName.c_str(), RTPathSuffix(Utf8Str(bstrSrcName).c_str()));
    11451145                            else if (   strSrcTest.startsWith("{")
    11461146                                     && strSrcTest.endsWith("}"))
     
    11501150                                Guid temp_guid(strSrcTest);
    11511151                                if (temp_guid.isValid() && !temp_guid.isZero())
    1152                                     strNewName = Utf8StrFmt("%s%s", newId.toStringCurly().c_str(), RTPathExt(strNewName.c_str()));
     1152                                    strNewName = Utf8StrFmt("%s%s", newId.toStringCurly().c_str(), RTPathSuffix(strNewName.c_str()));
    11531153                            }
    11541154                            else
    1155                                 strNewName = Utf8StrFmt("%s-disk%d%s", trgMCF.machineUserData.strName.c_str(), ++cDisks, RTPathExt(Utf8Str(bstrSrcName).c_str()));
     1155                                strNewName = Utf8StrFmt("%s-disk%d%s", trgMCF.machineUserData.strName.c_str(), ++cDisks,
     1156                                                        RTPathSuffix(Utf8Str(bstrSrcName).c_str()));
    11561157                        }
    11571158
  • trunk/src/VBox/Runtime/VBox/VBoxRTImp.def

    r48484 r49039  
    795795    RTPathExists
    796796    RTPathExistsEx
    797     RTPathExt
    798797    RTPathFilename
    799798    RTPathGetCurrent
    800799    RTPathGetMode
    801     RTPathHaveExt
    802800    RTPathHavePath
     801    RTPathHaveSuffix
    803802    RTPathJoin
    804803    RTPathJoinA
     
    819818    RTPathStartsWith
    820819    RTPathStartsWithRoot
    821     RTPathStripExt
    822820    RTPathStripFilename
     821    RTPathStripSuffix
    823822    RTPathStripTrailingSlash
     823    RTPathSuffix
    824824    RTPathTemp
    825825    RTPathTraverseList
  • trunk/src/VBox/Runtime/common/path/RTPathExt.cpp

    r48935 r49039  
    55
    66/*
    7  * Copyright (C) 2006-2012 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3333
    3434
    35 /**
    36  * Finds the extension part of in a path.
    37  *
    38  * @returns Pointer to extension within pszPath.
    39  * @returns NULL if no extension.
    40  * @param   pszPath     Path to find extension in.
    41  */
    42 RTDECL(char *) RTPathExt(const char *pszPath)
     35RTDECL(char *) RTPathSuffix(const char *pszPath)
    4336{
    4437    const char *psz = pszPath;
     
    6659            /* the end */
    6760            case '\0':
    68                 if (pszExt)
     61                if (pszExt && pszExt != pszPath && pszExt[1])
    6962                    return (char *)(void *)pszExt;
    7063                return NULL;
  • trunk/src/VBox/Runtime/common/path/RTPathHasExt.cpp

    r48935 r49039  
    55
    66/*
    7  * Copyright (C) 2006-2012 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3434
    3535
    36 /**
    37  * Checks if a path has an extension.
    38  *
    39  * @returns true if extension present.
    40  * @returns false if no extension present.
    41  * @param   pszPath     Path to check.
    42  */
    43 RTDECL(bool) RTPathHasExt(const char *pszPath)
     36RTDECL(bool) RTPathHasSuffix(const char *pszPath)
    4437{
    45     return RTPathExt(pszPath) != NULL;
     38    return RTPathSuffix(pszPath) != NULL;
    4639}
    4740
  • trunk/src/VBox/Runtime/common/path/RTPathStripExt.cpp

    r48935 r49039  
    55
    66/*
    7  * Copyright (C) 2006-2012 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3535
    3636
    37 /**
    38  * Strips the extension from a path.
    39  *
    40  * @param   pszPath     Path which extension should be stripped.
    41  */
    42 RTDECL(void) RTPathStripExt(char *pszPath)
     37RTDECL(void) RTPathStripSuffix(char *pszPath)
    4338{
    44     char *pszDot = NULL;
    45     for (;; pszPath++)
    46     {
    47         switch (*pszPath)
    48         {
    49             /* handle separators. */
    50 #if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
    51             case ':':
    52             case '\\':
    53 #endif
    54             case '/':
    55                 pszDot = NULL;
    56                 break;
    57             case '.':
    58                 pszDot = pszPath;
    59                 break;
    60 
    61             /* the end */
    62             case '\0':
    63                 if (pszDot)
    64                     *pszDot = '\0';
    65                 return;
    66         }
    67     }
    68     /* will never get here */
     39    char *pszSuffix = RTPathSuffix(pszPath);
     40    if (pszSuffix)
     41        *pszSuffix = '\0';
    6942}
    7043
  • trunk/src/VBox/Runtime/r3/posix/ldrNative-posix.cpp

    r48935 r49039  
    4646     * Do we need to add an extension?
    4747     */
    48     if (!RTPathHaveExt(pszFilename))
     48    if (!RTPathHasSuffix(pszFilename))
    4949    {
    5050#if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
  • trunk/src/VBox/Runtime/r3/win/ldrNative-win.cpp

    r48935 r49039  
    5858     * Do we need to add an extension?
    5959     */
    60     if (!RTPathHaveExt(pszFilename))
     60    if (!RTPathHasSuffix(pszFilename))
    6161    {
    6262        size_t cch = strlen(pszFilename);
  • trunk/src/VBox/Runtime/testcase/tstRTPath.cpp

    r45400 r49039  
    705705
    706706    /*
    707      * RTPathStripExt
    708      */
    709     RTTestSub(hTest, "RTPathStripExt");
     707     * RTPathStripSuffix
     708     */
     709    RTTestSub(hTest, "RTPathStripSuffix");
    710710    struct
    711711    {
     
    725725
    726726        strcpy(szPath, pszInput);
    727         RTPathStripExt(szPath);
     727        RTPathStripSuffix(szPath);
    728728        if (strcmp(szPath, pszResult))
    729729            RTTestIFailed("Unexpected result\n"
  • 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. --- */
  • trunk/src/VBox/VMM/VMMAll/IEMAllInstructions.cpp.h

    r47986 r49039  
    12211221                IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
    12221222                IEMOP_HLP_DECODED_NL_2(fIsLar ? OP_LAR : OP_LSL, IEMOPFORM_RM_MEM, OP_PARM_Gv, OP_PARM_Ew, DISOPTYPE_DANGEROUS | DISOPTYPE_PRIVILEGED_NOTRAP);
     1223/** @todo testcase: make sure it's a 16-bit read. */
    12231224
    12241225                IEM_MC_FETCH_MEM_U16(u16Sel, pIemCpu->iEffSeg, GCPtrEffSrc);
  • trunk/src/VBox/VMM/VMMR3/PDMLdr.cpp

    r46915 r49039  
    282282     */
    283283    const char *pszSuff = RTLdrGetSuff();
    284     size_t      cchSuff = RTPathHaveExt(pszFilename) ? 0 : strlen(pszSuff);
     284    size_t      cchSuff = RTPathHasSuffix(pszFilename) ? 0 : strlen(pszSuff);
    285285    PPDMMOD     pModule = (PPDMMOD)RTMemAllocZ(RT_OFFSETOF(PDMMOD, szFilename[cchFilename + cchSuff + 1]));
    286286    if (pModule)
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