sourcemm/util.cpp
author David Anderson <dvander@alliedmods.net>
Sun May 01 18:46:06 2005 +0000 (2005-05-01)
changeset 53 797ecc5394d6
parent 33 3c7faa7abf09
child 84 3f77bc9e64d8
permissions -rw-r--r--
Switched from MEMFUNC to STATICFUNC for simplicity
     1 /* ======== SourceMM ========
     2 * Copyright (C) 2004-2005 Metamod:Source Development Team
     3 * No warranties of any kind
     4 *
     5 * License: zlib/libpng
     6 *
     7 * Author(s): David "BAILOPAN" Anderson
     8 * ============================
     9 */
    10 
    11 #include <string.h>
    12 #include "util.h"
    13 
    14 /**
    15  * @brief Utility functons
    16  * @file util.cpp
    17  */
    18 
    19 /* UTIL_GetExtension
    20  * Returns a pointer to the extension in a file name
    21  */
    22 const char *UTIL_GetExtension(const char *file)
    23 {
    24 	int len = strlen(file);
    25 	int i = 0;
    26 
    27 	for (i=len-1; i>=0; i--)
    28 	{
    29 		if (file[i] == '/' || file[i] == '\\')
    30 			return NULL;
    31 
    32 		if ((file[i] == '.') && (i != len-1))
    33 		{
    34 			return (const char *)&(file[i+1]);
    35 		}
    36 	}
    37 
    38 	return NULL;
    39 }
    40