| 136 | |
| 137 | |
| 138 | ILstring iGetExtension(ILconst_string FileName) |
| 139 | { |
| 140 | ILboolean PeriodFound = IL_FALSE; |
| 141 | ILstring Ext = (ILstring)FileName; |
| 142 | ILint i, Len = ilStrLen(FileName); |
| 143 | |
| 144 | if (FileName == NULL || !Len) // if not a good filename/extension, exit early |
| 145 | return NULL; |
| 146 | |
| 147 | Ext += Len; // start at the end |
| 148 | |
| 149 | for (i = Len; i >= 0; i--) { |
| 150 | if (*Ext == '.') { // try to find a period |
| 151 | PeriodFound = IL_TRUE; |
| 152 | break; |
| 153 | } |
| 154 | Ext--; |
| 155 | } |
| 156 | |
| 157 | if (!PeriodFound) // if no period, no extension |
| 158 | return NULL; |
| 159 | |
| 160 | return Ext+1; |
| 161 | } |
| 162 | |
| 163 | |
| 164 | // Checks if the file exists |
no test coverage detected