add_file_extension

 

Description

Add file extension to given string

Syntax

bool add_file_extension( string & strFilename, LPCSTR lpcszExt )

Parameters

strFilename
[modify] filename to check and add extension
lpcszExt
[input] file extension, without the dot.

Return

true if extension is added, false if filename already has given extension

Examples

EX1

int add_file_extension_ex1()
{
    string str = GetAppPath() + "origin.ini";
    bool bRet = add_file_extension(str, "ini");
    ASSERT(!bRet);
    bRet = add_file_extension(str, "txt");
    ASSERT(bRet);
    string strFilename = GetFileName(str);
    ASSERT(strFilename == "origin.ini.txt");
    return 0;
}

Remark

See Also

check_add_file_ext

Header to Include

origin.h

Reference