ofxDirList::getExt(int pos)

hi, so I’m using ofxDirList addon, and needed to check the extension of a file.
The addon currently does allow extension filtering… but this method will let you check the extension of the filtered results.

ofxDirList.h

  
  
// after:  
		string getPath(int pos);  
  
// add:  
		string getExt(int pos);  
  

ofxDirList.cpp

  
  
//----------------------------------------------------------  
string ofxDirList::getExt(int pos){  
	if(pos >= count) return 0;  
  
	string ext = "";  
	string name = this->getName(pos);  
	int extPos = name.rfind('.');  
	if(extPos != string::npos){  
		ext = name.substr(extPos+1);  
	}  
	return ext;  
}  
  

Maybe this will find its way into the actual addon eventually. But for now, if you need the extension quickly, this will do it!

Cheers!