Find all Mdls Files in a Folder

Posted By: Puppeteer

Find all Mdls Files in a Folder - 05/11/14 10:40

Hi!

I need a list of all mdl files in a folder.
There was once a snippet around that could do just that but I wasn't able to find it.

Thank you
Puppeteer
Posted By: oliver2s

Re: Find all Mdls Files in a Folder - 05/11/14 10:55

Code:
//scan for mdl files
WIN32_FIND_DATA FindFileData;HANDLE hFind;STRING* tmp_str="";
str_cpy(tmp_str,STR_DIR);  //-> set directory (STR_DIR)
str_cat(tmp_str,"\\*.mdl");//Models
hFind=FindFirstFile(_chr(tmp_str),&FindFileData);
if(hFind!=INVALID_HANDLE_VALUE)
{
	int c=0; while(1) 
	{ 
		str_cpy((TEXT_file_list.pstring)[c],_str(FindFileData.cFileName));
		c++;

		if(!FindNextFile(hFind,&FindFileData)){break;}
	} 
}
FindClose(hFind);

Posted By: Superku

Re: Find all Mdls Files in a Folder - 05/11/14 11:46

There is a lite-C function for that, sadly not with the best name and thus hard(er) to find:

http://www.conitec.net/beta/txt_for_dir.htm
© 2024 lite-C Forums