Ejemplo n.º 1
0
/*----------------------------------------------------------------------
|   NPT_DirectoryAppendToPath
+---------------------------------------------------------------------*/
NPT_Result 
NPT_DirectoryAppendToPath(NPT_String& path, const char* value)
{
    if (!value) return NPT_ERROR_INVALID_PARAMETERS;

    NPT_String tmp = value;

    // make sure path will end with only one trailing delimiter
    path.TrimRight('/');
    path.TrimRight('\\');

    path += NPT_DIR_DELIMITER_STR;

    // make sure value to append doesn't start with delimiters
    tmp.TrimLeft('/');
    tmp.TrimLeft('\\');

    // append value
    path += tmp;

    // replace delimiters with the proper one for the platform
    path.Replace((NPT_DIR_DELIMITER_CHR == '/')?'\\':'/', NPT_DIR_DELIMITER_CHR);

    return NPT_SUCCESS;
}