static char *
get_regexp_name (const char *regexp, const char *path, gboolean dir)
{
	MateVFSResult result;
	GList *list, *node;
	MateVFSFileInfo *info;
	char *res = NULL;

	result = mate_vfs_directory_list_load (
		&list, path, MATE_VFS_FILE_INFO_DEFAULT);

	if (show_if_error (result, "open directory ", path))
		return NULL;

	for (node = list; node != NULL; node = node->next) {
		info = node->data;

		if (simple_regexp (regexp, info->name)) {
			if (info->valid_fields & MATE_VFS_FILE_INFO_FIELDS_TYPE) {
				if ((dir  && info->type == MATE_VFS_FILE_TYPE_DIRECTORY) ||
				    (!dir && info->type != MATE_VFS_FILE_TYPE_DIRECTORY)) {
					res = g_strdup (info->name);
					break;
				}
			} else {
				fprintf (vfserr, "Can't cope with no type data");
				res = g_strdup (info->name);
				break;
			}
		}
	}
	mate_vfs_file_info_list_free (list);

	return res;
}
Example #2
0
/*
 * This should take a path to check the directory out there.
 */ 
static char *
get_regexp_name (const char *regexp, const char *path, MsOle *ole)
{
	char      *res = NULL;
	char     **names;
	MsOleErr   result;
	int        lp;

	result = ms_ole_directory (&names, ole, path);
	if (result != MS_OLE_ERR_OK) {
		g_warning ("Failed dir");
		return NULL;
	}

	if (!names [0])
		printf ("Empty directory\n");

	for (lp = 0; names[lp]; lp++) {
		if (simple_regexp (regexp, names [lp])) {
			res = g_strdup (names [lp]);
			break;
		}
	}

	return res;
}