1 /* ======== SourceMM ========
2 * Copyright (C) 2004-2005 Metamod:Source Development Team
3 * No warranties of any kind
7 * Author(s): David "BAILOPAN" Anderson
8 * ============================
16 * @brief Utility functons
21 * Returns a pointer to the extension in a file name
23 const char *UTIL_GetExtension(const char *file)
25 int len = strlen(file);
28 for (i=len-1; i>=0; i--)
30 if (file[i] == '/' || file[i] == '\\')
33 if ((file[i] == '.') && (i != len-1))
35 return (const char *)&(file[i+1]);
43 * Removes whitespace characters from left side of string
45 void UTIL_TrimLeft(char *buffer)
47 // Let's think of this as our iterator
50 // Make sure the buffer isn't null
53 // Add up number of whitespace characters
57 // If whitespace chars in buffer then adjust string so first non-whitespace char is at start of buffer
59 memcpy(buffer, i, (strlen(i) + 1) * sizeof(char));
64 * Removes whitespace characters from right side of string
66 void UTIL_TrimRight(char *buffer)
68 // Make sure buffer isn't null
71 // Loop through buffer backwards while replacing whitespace chars with null chars
72 for (unsigned int i = strlen(buffer) - 1; i >= 0; i--)
74 if (isspace(buffer[i]))