2.1.10.35 is_str_valid_for_filename


Description

Check to see if specified string is a valid file name, no path is allowed

Syntax

bool is_str_valid_for_filename( string & strName, bool bAutoCorrect = false )

Parameters

strName
[input] filename to check
bAutoCorrect
[input] default is false, if true, will change the string to valid C name string

Return

true if strName is not empty and does not contain illegal characters or have been put right correctly

false if strName contains path or has other invalid characters for filename or can't be put right correctly

Examples

EX1

int is_str_valid_for_filename_ex1()
{
    string str = "origin*.ini";
    ASSERT(!is_str_valid_for_filename(str));
    str = "origin.ini";
    ASSERT(is_str_valid_for_filename(str));
    str = GetAppPath() + "origin.ini";
    ASSERT(str.IsFile());
    ASSERT(!is_str_valid_for_filename(str));
    
    
    str = "abc?ef";
    ASSERT(!is_str_valid_for_filename(str));
    str = "abcef";
    ASSERT(is_str_valid_for_filename(str));
    return 0;
}

Remark

See Also

Header to Include

origin.h

Reference