MCPcopy Create free account
hub / github.com/DentonW/DevIL / iCheckExtension

Function iCheckExtension

DevIL/src-IL/src/il_internal.cpp:108–135  ·  view source on GitHub ↗

Simple function to test if a filename has a given extension, disregarding case

Source from the content-addressed store, hash-verified

106
107// Simple function to test if a filename has a given extension, disregarding case
108ILboolean iCheckExtension(ILconst_string Arg, ILconst_string Ext)
109{
110 ILboolean PeriodFound = IL_FALSE;
111 ILint i, Len;
112 ILstring Argu = (ILstring)Arg;
113
114 if (Arg == NULL || Ext == NULL || !ilStrLen(Arg) || !ilStrLen(Ext)) // if not a good filename/extension, exit early
115 return IL_FALSE;
116
117 Len = ilStrLen(Arg);
118 Argu += Len; // start at the end
119
120 for (i = Len; i >= 0; i--) {
121 if (*Argu == '.') { // try to find a period
122 PeriodFound = IL_TRUE;
123 break;
124 }
125 Argu--;
126 }
127
128 if (!PeriodFound) // if no period, no extension
129 return IL_FALSE;
130
131 if (!iStrCmp(Argu+1, Ext)) // extension and ext match?
132 return IL_TRUE;
133
134 return IL_FALSE; // if all else fails, return IL_FALSE
135}
136
137
138ILstring iGetExtension(ILconst_string FileName)

Callers 15

ilIsValidLifFunction · 0.85
ilIsValidPicFunction · 0.85
ilIsValidSgiFunction · 0.85
ilisValidTiffExtensionFunction · 0.85
ilIsValidJp2Function · 0.85
ilIsValidDcxFunction · 0.85
ilIsValidDicomFunction · 0.85
ilIsValidBlpFunction · 0.85
ilIsValidPsdFunction · 0.85
ilIsValidIlbmFunction · 0.85
ilIsValidGifFunction · 0.85
ilIsValidXpmFunction · 0.85

Calls 2

ilStrLenFunction · 0.85
iStrCmpFunction · 0.85

Tested by

no test coverage detected