int flist_find_name(struct file_list *flist, const char *fname, int want_dir_match)
{
	static struct file_struct *f;
	char fbuf[MAXPATHLEN];
	const char *slash = strrchr(fname, '/');
	const char *basename = slash ? slash+1 : fname;

	if (!f)
		f = (struct file_struct*)new_array(char, FILE_STRUCT_LEN + MAXPATHLEN + 1);

	memset(f, 0, FILE_STRUCT_LEN);
	memcpy((void*)f->basename, basename, strlen(basename)+1);

	if (slash) {
		strlcpy(fbuf, fname, slash - fname + 1);
		f->dirname = fbuf;
	} else
		f->dirname = NULL;

	f->mode = want_dir_match > 0 ? S_IFDIR : S_IFREG;

	if (want_dir_match < 0)
		return flist_find_ignore_dirness(flist, f);
	return flist_find(flist, f);
}
int flist_find_name(struct file_list *flist, const char *fname, int want_dir_match)
{
	static struct file_struct *f;
	char fbuf[MAXPATHLEN];
	const char *slash = strrchr(fname, '/');
	const char *basename = slash ? slash+1 : fname;

	if (!f)
		f = (struct file_struct*)new_array(char, FILE_STRUCT_LEN + MAXPATHLEN + 1);

	memset(f, 0, FILE_STRUCT_LEN);
	memcpy((void*)f->basename, basename, strlen(basename)+1);

	if (slash) {
		strlcpy(fbuf, fname, slash - fname + 1);
		f->dirname = fbuf;
	} else
		f->dirname = NULL;

	f->mode = want_dir_match > 0 ? S_IFDIR : S_IFREG;

	if (want_dir_match < 0)
		return flist_find_ignore_dirness(flist, f);
	return flist_find(flist, f);
}