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

Function GetExtension

DevIL/examples/windows_example/BatchConv.cpp:107–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105
106
107TCHAR *GetExtension(const TCHAR *FileName)
108{
109 bool PeriodFound = false;
110 TCHAR *Ext = (TCHAR*)FileName;
111 long i, Len = (long)wcslen(FileName);
112
113 if (FileName == NULL || !Len) // if not a good filename/extension, exit early
114 return NULL;
115
116 Ext += Len; // start at the end
117
118 for (i = Len; i >= 0; i--) {
119 if (*Ext == '.') { // try to find a period
120 PeriodFound = true;
121 break;
122 }
123 Ext--;
124 }
125
126 if (!PeriodFound) // if no period, no extension
127 return NULL;
128
129 return Ext+1;
130}
131
132
133// Simple function to test if a filename has a given extension, disregarding case

Callers 4

GetPrevImageFunction · 0.85
GetNextImageFunction · 0.85
GetPrevImageFunction · 0.85
GetNextImageFunction · 0.85

Calls

no outgoing calls

Tested by 2

GetPrevImageFunction · 0.68
GetNextImageFunction · 0.68