====== file_GetExt ====== ===== Description ===== Get the file extension of a filename. ===== Function prototype ===== bool CExtAPI::file_GetExt(ZVAR hStr, const char* lpFileName); ===== Arguments ===== ^ Name ^ Type ^ Comment ^ | hStr | ZVAR | A ZVAR handle to a string variable to receive the extension string. | | lpFileName | const char* | A handle to a C-style string containing the file name, the extension of which is to be determined. | ===== Return value ===== False if no extension was found or if an error occurred, and true otherwise (with //hStr// containing the file extension, without the dot). ===== Comments ===== ==== Multiple extensions ==== If a file has multiple extensions, such as 'test.tar.gz', file_GetExt will return the whole extension string (e.g. 'tar.gz'). To get the last extension, call file_GetExt recursively on the file extension until false is returned. ===== Example ===== Taken from [[bundywiki>plugins:fileio:L3DTio_FI|L3DTio_FI.DLL]]: ... // create a temp var to contain the file extension ZVAR hStr = theAPI.var_CreateTemp(VarID_string); if(!hStr) return false; // get the file extension of lpFileName argument if(!theAPI.file_GetExt(hStr, lpFileName)) { theAPI.var_Delete(hStr); return false; } char FileExt[MAX_PATH]; // declare a char array, into which we'll put the file extension sprintf(FileExt, "%s", theAPI.str_GetText(hStr)); theAPI.var_Delete(hStr); // done with the temp string var, so delete ...