UTIL GetModDir: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Added {{lang}} and function elaboration.)
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{lang|UTIL GetModDir|title=UTIL_GetModDir}}
{{lang|UTIL GetModDir|title=UTIL_GetModDir}}
A [[UTIL]] function that retrieves the mod (or game) directory name for the active game (ie. "hl2", "csgo", or "tf"), by storing the game directory path in <code>lpszTextOut</code> and then culls the entire directory path, leaving only the directory name. This function returns false if the length of the game directory path is longer than <code>nSize</code>, otherwise it will return true.
{{ent|UTIL_GetModDir}} is a [[UTIL]] function that retrieves the mod (or game) directory name for the active game (ie. "hl2", "csgo", or "tf"), by storing the game directory path in <code>lpszTextOut</code> and then culls the entire directory path, leaving only the directory name. This function returns false if the length of the game directory path is longer than <code>nSize</code>, otherwise it will return true.


==Usage==
==Usage==
<source lang="cpp">
<source lang=cpp>
/* lpszTextOut - The input C-style string to be written to.
/* lpszTextOut - The input C-style string to be written to.
   nSize - String length. */
   nSize - String length. */
bool UTIL_GetModDir( char *lpszTextOut, unsigned int nSize )
bool UTIL_GetModDir( char *lpszTextOut, unsigned int nSize );
</source>
</source>


Line 12: Line 12:
Get mod directory and store it.
Get mod directory and store it.
<source lang=cpp>
<source lang=cpp>
    char pGameDir[1024];
char pGameDir[1024];
    UTIL_GetModDir( pGameDir, 1024 );
UTIL_GetModDir( pGameDir, 1024 );
</source>
</source>


[[Category:Programming]]
[[Category:UTIL]]
[[Category:UTIL]]

Latest revision as of 19:58, 2 November 2021

English (en)Translate (Translate)

UTIL_GetModDir is a UTIL function that retrieves the mod (or game) directory name for the active game (ie. "hl2", "csgo", or "tf"), by storing the game directory path in lpszTextOut and then culls the entire directory path, leaving only the directory name. This function returns false if the length of the game directory path is longer than nSize, otherwise it will return true.

Usage

/* lpszTextOut - The input C-style string to be written to.
   nSize - String length. */
bool UTIL_GetModDir( char *lpszTextOut, unsigned int nSize );

Example

Get mod directory and store it.

char pGameDir[1024];
UTIL_GetModDir( pGameDir, 1024 );