VirtualBox

Changeset 34570 in vbox


Ignore:
Timestamp:
Dec 1, 2010 1:33:49 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
68364
Message:

ExtPackUtil.cpp: The underscore=space trick.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ExtPackUtil.cpp

    r34307 r34570  
    245245     * Skip ahead to the filename part and count the number of characters
    246246     * that matches the criteria for a extension pack name.
     247     *
     248     * Trick: '_' == ' ' - filenames with spaces cause trouble.
    247249     */
    248250    const char *pszSrc = RTPathFilename(pszTarball);
     
    251253
    252254    size_t off = 0;
    253     while (RT_C_IS_ALNUM(pszSrc[off]) || pszSrc[off] == ' ')
     255    while (RT_C_IS_ALNUM(pszSrc[off]) || pszSrc[off] == ' ' || pszSrc[off] == '_')
    254256        off++;
    255257
     
    257259     * Check min and max name limits.
    258260     */
    259     if (   off > VBOX_EXTPACK_NAME_MIN_LEN
     261    if (   off > VBOX_EXTPACK_NAME_MAX_LEN
    260262        || off < VBOX_EXTPACK_NAME_MIN_LEN)
    261263        return NULL;
    262264
    263265    /*
    264      * Make a duplicate of the name and return it.
    265      */
    266     iprt::MiniString *pStrRet = new iprt::MiniString(pszSrc, off);
    267     Assert(VBoxExtPackIsValidName(pStrRet->c_str()));
     266     * Replace underscores, duplicate the string and return it.
     267     * (Unforuntately, iprt::ministring does not offer simple search & replace.)
     268     */
     269    char szTmp[VBOX_EXTPACK_NAME_MAX_LEN + 1];
     270    memcpy(szTmp, pszSrc, off);
     271    szTmp[off] = '\0';
     272    char *psz = szTmp;
     273    while ((psz = strchr(psz, '_')) != NULL)
     274        *psz++ = ' ';
     275    Assert(VBoxExtPackIsValidName(szTmp));
     276
     277    iprt::MiniString *pStrRet = new iprt::MiniString(szTmp, off);
    268278    return pStrRet;
    269279}
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