nsXPIDLCString baseName; if ( NS_SUCCEEDED( localFile->GetLeafName( getter_Copies( baseName ) ) ) ) {  result = nsUnescape( (char*)(const char*)baseName );
nsXPIDLString baseName; if ( NS_SUCCEEDED( localFile->GetUnicodeLeafName( getter_Copies( baseName ) ) ) ) { result = baseName.get();
nsCString nsStreamTransfer::SuggestNameFor( nsIChannel *aChannel, char const *suggestedName ) {    nsCString result(suggestedName);    if ( !result.IsEmpty() ) {        // Exclude any path information from this!  This is mandatory as        // this suggested name comes from a http response header and could        // try to overwrite c:\config.sys or something.        nsCOMPtr<nsILocalFile> localFile;        if ( NS_SUCCEEDED( NS_NewLocalFile( result, PR_FALSE, getter_AddRefs( localFile ) ) ) ) {            // We want base part of name only.            nsXPIDLCString baseName;            if ( NS_SUCCEEDED( localFile->GetLeafName( getter_Copies( baseName ) ) ) ) {                // Unescape this for display in dialog.                result = nsUnescape( (char*)(const char*)baseName );            }        }    } else if ( aChannel ) {        // Get URI from channel and spec from URI.        nsCOMPtr<nsIURI> uri;        nsresult rv = aChannel->GetURI( getter_AddRefs( uri ) );        if ( NS_SUCCEEDED( rv ) && uri ) {            // Try to get URL from URI.            nsCOMPtr<nsIURL> url( do_QueryInterface( uri, &rv ) );            if ( NS_SUCCEEDED( rv ) && url ) {                char *nameFromURL = 0;                rv = url->GetFileName( &nameFromURL );                if ( NS_SUCCEEDED( rv ) && nameFromURL ) {                    // Unescape the file name (GetFileName escapes it).                    result = nsUnescape( nameFromURL );                    nsCRT::free( nameFromURL );                }            }        }    }    return result;}