loader.cpp: improved file extension checking, made Upper/LowerStr useful

Instead of forcibly taking the last 4 characters, it now finds the last extension separator (the period) and takes a substr of its location.
Use a range-based for loop for this instead, please. Cleaner + in theory slightly better performance ;)