rts_winFiles.h 986 Bytes
#include "rtsFilename.h"

#include <windows.h>
#include <vector>


vector<rtsFilename> rts_winGetFileList(const char* mask)
{
	/*This function returns a list of file names based on the mask passed by
	the user.  The value returned is the number of rtsFilename elements in the
	file_list parameter.*/
	
	//create a temporary vector to store the file names
	vector<rtsFilename> result;
	//create a handle for the search
	HANDLE search_handle;
	WIN32_FIND_DATA found_data;

	//start the search
	search_handle = FindFirstFile((LPCSTR)mask, &found_data);

	//loop through the rest of the data
	rtsFilename new_file;
	if(search_handle != INVALID_HANDLE_VALUE)
	{
		//save the first filename
		new_file = found_data.cFileName;
		result.push_back(new_file);
		
		//now loop through the rest of the files
		while(FindNextFile(search_handle, &found_data))
		{
			new_file = found_data.cFileName;
			result.push_back(new_file);
		}
	}

	return result;
}