cpl/cpl_path.cpp
const char *CPLGetBasename( const char *pszFullFilename )

{
    size_t  iFileStart = CPLFindFilenameStart( pszFullFilename );
    size_t  iExtStart, nLength;
    char    *pszStaticResult = CPLGetStaticResult();

    for( iExtStart = strlen(pszFullFilename);
         iExtStart > iFileStart && pszFullFilename[iExtStart] != '.';
         iExtStart-- ) {}

    if( iExtStart == iFileStart )
        iExtStart = strlen(pszFullFilename);

    nLength = iExtStart - iFileStart;

    CPLAssert( nLength < CPL_PATH_BUF_SIZE );

    strncpy( pszStaticResult, pszFullFilename + iFileStart, nLength );
    pszStaticResult[nLength] = '\0';

    return pszStaticResult;
}
/**
 * Extract basename (non-directory, non-extension) portion of filename.
 *
 * Returns a string containing the file basename portion of the passed
 * name.  If there is no basename (passed value ends in trailing directory
 * separator, or filename starts with a dot) an empty string is returned.
 *
 * <pre>
 * CPLGetBasename( "abc/def.xyz" ) == "def"
 * CPLGetBasename( "abc/def" ) == "def"
 * CPLGetBasename( "abc/def/" ) == ""
 * </pre>
 *
 * @param pszFullFilename the full filename potentially including a path.
 *
 * @return just the non-directory, non-extension portion of the path in
 * an internal string which must not be freed.  The string
 * may be destroyed by the next CPL filename handling call.
 */
Extract basename (non-directory, non-extension) portion of filename.
Returns a string containing the file basename portion of the passed
name.  If there is no basename (passed value ends in trailing directory
separator, or filename starts with a dot) an empty string is returned.



@param pszFullFilename the full filename potentially including a path.

@return just the non-directory, non-extension portion of the path in
an internal string which must not be freed.  The string
may be destroyed by the next CPL filename handling call.
Extract basename ( non - directory non - extension ) portion of filename . Returns a string containing the file basename portion of the passed name . If there is no basename ( passed value ends in trailing directory separator or filename starts with a dot ) an empty string is returned . @param pszFullFilename the full filename potentially including a path . @return just the non - directory non - extension portion of the path in an internal string which must not be freed . The string may be destroyed by the next CPL filename handling call .
const char *CPLGetBasename( const char *pszFullFilename )
{
    size_t  iFileStart = CPLFindFilenameStart( pszFullFilename );
    size_t  iExtStart, nLength;
    char    *pszStaticResult = CPLGetStaticResult();
    for( iExtStart = strlen(pszFullFilename);
         iExtStart > iFileStart && pszFullFilename[iExtStart] != '.';
         iExtStart-- ) {}
    if( iExtStart == iFileStart )
        iExtStart = strlen(pszFullFilename);
    nLength = iExtStart - iFileStart;
    CPLAssert( nLength < CPL_PATH_BUF_SIZE );
    strncpy( pszStaticResult, pszFullFilename + iFileStart, nLength );
    pszStaticResult[nLength] = '\0';
    return pszStaticResult;
}
const char * CPLGetBasename ( const char * pszFullFilename ) { size_t iFileStart = CPLFindFilenameStart ( pszFullFilename ) ; size_t iExtStart , nLength ; char * pszStaticResult = CPLGetStaticResult ( ) ; for ( iExtStart = strlen ( pszFullFilename ) ; iExtStart > iFileStart && pszFullFilename [ iExtStart ] != ' ' ; iExtStart -- ) { } if ( iExtStart == iFileStart ) iExtStart = strlen ( pszFullFilename ) ; nLength = iExtStart - iFileStart ; CPLAssert ( nLength < CPL_PATH_BUF_SIZE ) ; strncpy ( pszStaticResult , pszFullFilename + iFileStart , nLength ) ; pszStaticResult [ nLength ] = ' \0 ' ; return pszStaticResult ; }
Extract basename (non-directory, non-extension) portion of filename.
Extract basename ( non - directory non - extension ) portion of filename .