Esempio n. 1
0
bool tail_compare(
			const std::string &filename,
			const std::string &extension )
{
	return c_tail_compare( filename.c_str(),
		filename.size(),
		extension.c_str(),
		extension.size() );
}
Esempio n. 2
0
bool tail_compare(
	const std::string &filename,
	const std::vector<std::string> &ext_list )
{
	for ( std::vector<std::string>::const_iterator itr=ext_list.begin();
			itr != ext_list.end(); ++itr )
	{
		if ( c_tail_compare( filename.c_str(),
				filename.size(),
				(*itr).c_str(),
				(*itr).size() ) )
			return true;

	}

	return false;
}
Esempio n. 3
0
bool get_filename_from_base(
	std::vector<std::string> &in_list,
	std::vector<std::string> &out_list,
	const std::string &path,
	const std::string &base_name,
	const char **filter )
{
#ifdef SFML_SYSTEM_WINDOWS
	std::string temp = path + base_name + "*";

	struct _finddata_t t;
	intptr_t srch = _findfirst( temp.c_str(), &t );

	if  ( srch < 0 )
		return false;

	do
	{
		const char *what = t.name;
		size_t what_len = strlen( what );

		if (( strcmp( what, "." ) != 0 )
				&& ( strcmp( what, ".." ) != 0 ))
		{
#else

	DIR *dir;
	struct dirent *ent;

	if ( (dir = opendir( path.c_str() )) == NULL )
		return false;

	while ((ent = readdir( dir )) != NULL )
	{
		const char *what = ent->d_name;
		size_t what_len = strlen( what );
		size_t base_len = base_name.size();

		if (( strcmp( what, "." ) != 0 )
				&& ( strcmp( what, ".." ) != 0 )
				&& ( what_len >= base_len )
				&& ( strncasecmp( what, base_name.c_str(), base_len ) == 0 ))
		{
#endif // SFML_SYSTEM_WINDOWS
			if ( filter )
			{
				bool add=false;
				int i=0;
				while ( filter[i] != NULL )
				{
					if ( c_tail_compare( what,
						what_len,
						filter[i],
						strlen( filter[i] ) ) )
					{
						add=true;
						break;
					}
					i++;
				}

				if ( add )
					in_list.push_back( path + what );
				else
					out_list.push_back( path + what );
			}
			else
				in_list.push_back( path + what );
#ifdef SFML_SYSTEM_WINDOWS
		}
	} while ( _findnext( srch, &t ) == 0 );
	_findclose( srch );
#else
		}
	}
	closedir( dir );
#endif // SFML_SYSTEM_WINDOWS

	return !(in_list.empty());
}