VirtualBox

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

IPRT: Filename extension versus suffix cleanup, long overdue.

Location:
trunk/src/VBox/Runtime/common/path
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • 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
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