====== zfile_GetExt ====== ===== Description ===== Get the file extension of a file name. ===== Files ===== ^ Declaration | ''zFile.h'' | ^ Implementation | ''zFile.cpp'' | ===== Function prototype ===== bool zfile_GetExt(const char* lpFileName, ZSTR hResult); ===== Arguments ===== ^ Name ^ Type ^ Comment ^ | //lpFileName// | ''const char*'' | A handle to a C-style string containing the file name, the extension of which is to be determined. | | //hResult// | ''ZSTR'' | A [[zeolite:types:ZSTR]] handle to a string variable that is to receive the extension string. | ===== Return value ===== False if no extension was found or if an error occurred, and true otherwise (with //hResult// containing the file extension, without the dot). ===== Comments ===== ==== Multiple extensions ==== If a file has multiple extensions, such as 'test.tar.gz', ''zfile_GetExt'' will return the whole extension string (e.g. 'tar.gz'). To get the last extension, call ''zfile_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 = zvar_Create(VarID_string); if(!hStr) return false; // get the file extension of lpFileName argument if(!zfile_GetExt(lpFileName, hStr)) { zvar_Delete(hStr); return false; } char FileExt[MAX_PATH]; // declare a char array, into which we'll put the file extension strcpy(FileExt, zstr_GetText(hStr)); zvar_Delete(hStr); // done with the temp string var, so delete ...