Example #1
0
static gboolean
test_equal (gchar *pattern1,
	    gchar *pattern2,
	    gboolean expected)
{
  GPatternSpec *p1 = g_pattern_spec_new (pattern1);
  GPatternSpec *p2 = g_pattern_spec_new (pattern2);
  gboolean equal = g_pattern_spec_equal (p1, p2);

  verbose ("comparing \"%s\" with \"%s\" \t", pattern1, pattern2);

  if (expected != equal)
    {
      g_print ("failed \t{%s, %u, \"%s\"} %s {%s, %u, \"%s\"}\n",
	       match_type_name (p1->match_type), p1->pattern_length, p1->pattern,
	       expected ? "!=" : "==",
	       match_type_name (p2->match_type), p2->pattern_length, p2->pattern);
    }
  else
    verbose ("passed (%s)\n", equal ? "equal" : "unequal");
  
  g_pattern_spec_free (p1);
  g_pattern_spec_free (p2);

  return expected == equal;
}
Example #2
0
static gboolean
test_compilation (gchar *src, 
		  GMatchType match_type, 
		  gchar *pattern,
		  guint min)
{
  GPatternSpec *spec; 

  verbose ("compiling \"%s\" \t", src);
  spec = g_pattern_spec_new (src);

  if (spec->match_type != match_type)
    {
      g_print ("failed \t(match_type: %s, expected %s)\n",
	       match_type_name (spec->match_type), 
	       match_type_name (match_type));
      g_pattern_spec_free (spec);
      return FALSE;
    }
  
  if (strcmp (spec->pattern, pattern) != 0)
    {
      g_print ("failed \t(pattern: \"%s\", expected \"%s\")\n",
	       spec->pattern,
	       pattern);
      g_pattern_spec_free (spec);
      return FALSE;
    }
  
  if (spec->pattern_length != strlen (spec->pattern))
    {
      g_print ("failed \t(pattern_length: %d, expected %d)\n",
	       spec->pattern_length,
	       (gint)strlen (spec->pattern));
      g_pattern_spec_free (spec);
      return FALSE;
    }
  
  if (spec->min_length != min)
    {
      g_print ("failed \t(min_length: %d, expected %d)\n",
	       spec->min_length,
	       min);
      g_pattern_spec_free (spec);
      return FALSE;
    }
  
  verbose ("passed (%s: \"%s\")\n",
	   match_type_name (spec->match_type),
	   spec->pattern);

  g_pattern_spec_free (spec);
  
  return TRUE;
}
Example #3
0
void
mud_connections_icon_fileset_cb(GtkFileChooserButton *chooser,
				MudConnections *conn)
{
    const gchar *file;
    gchar *current_folder =
	gtk_file_chooser_get_current_folder(
	    GTK_FILE_CHOOSER(conn->priv->icon_dialog_chooser));
    GDir *dir = g_dir_open(current_folder ,0, NULL);
    GPatternSpec *xpm_pattern = g_pattern_spec_new("*.xpm");
    GPatternSpec *svg_pattern = g_pattern_spec_new("*.svg");
    GPatternSpec *bmp_pattern = g_pattern_spec_new("*.bmp");
    GPatternSpec *png_pattern = g_pattern_spec_new("*.png");

    gtk_list_store_clear(
	GTK_LIST_STORE(conn->priv->icon_dialog_view_model));

    while( (file = g_dir_read_name(dir) ) != NULL)
	if( g_pattern_match_string(xpm_pattern, file) ||
	    g_pattern_match_string(svg_pattern, file) ||
	    g_pattern_match_string(bmp_pattern, file) ||
	    g_pattern_match_string(png_pattern, file))
	{
	    gchar *full_path = g_strconcat(current_folder,
					   G_DIR_SEPARATOR_S,
					   file, NULL);
	    GdkPixbuf *icon = gdk_pixbuf_new_from_file_at_size(
		full_path, 48, 48, NULL);
	    GtkTreeIter iter;

            if(icon)
            {
                gtk_list_store_append(
                        GTK_LIST_STORE(conn->priv->icon_dialog_view_model),
                        &iter);
                gtk_list_store_set(
                        GTK_LIST_STORE(conn->priv->icon_dialog_view_model),
                        &iter,
                        MODEL_COLUMN_STRING, file,
                        MODEL_COLUMN_PIXBUF, icon,
                        -1);

                g_object_unref(icon);
            }

	    g_free(full_path);
	}

    g_free(current_folder);
    g_dir_close(dir);
    g_pattern_spec_free(xpm_pattern);
    g_pattern_spec_free(svg_pattern);
    g_pattern_spec_free(bmp_pattern);
    g_pattern_spec_free(png_pattern);
}
static void
gkm_file_tracker_finalize (GObject *obj)
{
	GkmFileTracker *self = GKM_FILE_TRACKER (obj);

	if (self->include)
		g_pattern_spec_free (self->include);
	if (self->exclude)
		g_pattern_spec_free (self->exclude);
	g_free (self->directory_path);

	g_hash_table_destroy (self->files);

	G_OBJECT_CLASS (gkm_file_tracker_parent_class)->finalize (obj);
}
static GList *
games_file_list_new_internal (const gchar * glob, va_list path)
{
  GPatternSpec *filespec = g_pattern_spec_new (glob);
  gchar *pathelement;
  GList *list = NULL;
  GDir *dir;
  const gchar *filename;
  gchar *fullname;

  while ((pathelement = va_arg (path, gchar *)) != NULL) {
    dir = g_dir_open (pathelement, 0, NULL);
    if (dir != NULL) {
      while ((filename = g_dir_read_name (dir)) != NULL) {
	if (g_pattern_match_string (filespec, filename)) {
	  fullname = g_build_filename (pathelement, filename, NULL);
	  if (g_file_test (fullname, G_FILE_TEST_IS_REGULAR)) {
	    list = g_list_append (list, fullname);
	  } else
	    g_free (fullname);
	}
      }
      g_dir_close (dir);
    }
  }

  g_pattern_spec_free (filespec);

  return list;
}
Example #6
0
static void
log_matcher_glob_free(LogMatcher *s)
{
  LogMatcherGlob *self = (LogMatcherGlob *)s;
  g_pattern_spec_free(self->pattern);
  log_matcher_free_method(s);
}
Example #7
0
static GList *
_get_views(const gchar *filter)
{
  GPatternSpec *pattern = g_pattern_spec_new(filter);
  GList *views = NULL;
  gpointer key, value;
  GHashTableIter iter;
  gboolean single_match;

  single_match = _is_single_match(filter);

  g_static_mutex_lock(&stats_query_mutex);
  g_hash_table_iter_init(&iter, stats_views);
  while (g_hash_table_iter_next(&iter, &key, &value))
    {
      if (_is_pattern_matches_key(pattern, key))
        {
          ViewRecord *view = (ViewRecord *) value;
          views = g_list_append(views, view);

          if (single_match)
            break;
        }
    }
  g_static_mutex_unlock(&stats_query_mutex);

  g_pattern_spec_free(pattern);
  return views;
}
Example #8
0
static GList *
_query_counter_hash(const gchar *key_str)
{
  GPatternSpec *pattern = g_pattern_spec_new(key_str);
  GList *counters = NULL;
  gpointer key, value;
  GHashTableIter iter;
  gboolean single_match;

  _update_index();
  single_match = _is_single_match(key_str);

  g_static_mutex_lock(&stats_query_mutex);
  g_hash_table_iter_init(&iter, counter_index);
  while (g_hash_table_iter_next(&iter, &key, &value))
    {
      if (_is_pattern_matches_key(pattern, key))
        {
          StatsCounterItem *counter = (StatsCounterItem *) value;
          counters = g_list_append(counters, counter);

          if (single_match)
            break;
        }
    }
  g_static_mutex_unlock(&stats_query_mutex);

  g_pattern_spec_free(pattern);
  return counters;
}
Example #9
0
GList *
nautilus_directory_match_pattern (NautilusDirectory *directory, const char *pattern)
{
	GList *files, *l, *ret;
	GPatternSpec *spec;


	ret = NULL;
	spec = g_pattern_spec_new (pattern);
	
	files = nautilus_directory_get_file_list (directory);
	for (l = files; l; l = l->next) {
		NautilusFile *file;
		char *name;
	       
	        file = NAUTILUS_FILE (l->data);
		name = nautilus_file_get_display_name (file);

		if (g_pattern_match_string (spec, name)) {
			ret = g_list_prepend(ret, nautilus_file_ref (file));	
		}

		g_free (name);
	}

	g_pattern_spec_free (spec);
	nautilus_file_list_free (files);

	return ret;
}
Example #10
0
static void find_file(GtkTreeIter *iter)
{
	gchar *pattern_str = NULL;
	gboolean case_sensitive, is_full_path;
	gchar *utf8_path = build_path(iter);

	if (show_dialog_find_file(iter ? utf8_path : NULL, &pattern_str, &case_sensitive, &is_full_path) == GTK_RESPONSE_ACCEPT)
	{
		gchar *utf8_base_path = get_project_base_path();
		gchar *locale_base_path = utils_get_locale_from_utf8(utf8_base_path);
		GPatternSpec *pattern;

		if (!case_sensitive)
			SETPTR(pattern_str, g_utf8_strdown(pattern_str, -1));

		pattern = g_pattern_spec_new(pattern_str);

		msgwin_clear_tab(MSG_MESSAGE);
		msgwin_set_messages_dir(locale_base_path);
		find_file_recursive(iter, case_sensitive, is_full_path, pattern);
		msgwin_switch_tab(MSG_MESSAGE, TRUE);
		g_free(utf8_base_path);
		g_free(locale_base_path);
		g_pattern_spec_free(pattern);
	}

	g_free(pattern_str);
	g_free(utf8_path);
}
/*! \brief Find all text objects that match a pattern
 *
 *  \param pages the list of pages to search
 *  \param text the pattern to match
 *  \return a list of objects that match the given pattern
 */
static GSList*
find_objects_using_pattern (GSList *pages, const char *text)
{
  GSList *object_list = NULL;
  GSList *page_iter = pages;
  GPatternSpec *pattern;

  g_return_val_if_fail (text != NULL, NULL);

  pattern = g_pattern_spec_new (text);

  while (page_iter != NULL) {
    const GList *object_iter;
    PAGE *page = (PAGE*) page_iter->data;

    page_iter = g_slist_next (page_iter);

    if (page == NULL) {
      g_warning ("NULL page encountered");
      continue;
    }

    object_iter = s_page_objects (page);

    while (object_iter != NULL) {
      OBJECT *object = (OBJECT*) object_iter->data;
      const char *str;

      object_iter = g_list_next (object_iter);

      if (object == NULL) {
        g_warning ("NULL object encountered");
        continue;
      }

      if (object->type != OBJ_TEXT) {
        continue;
      }

      if (!(o_is_visible (page->toplevel, object) || page->toplevel->show_hidden_text)) {
        continue;
      }

      str = geda_text_object_get_string (object);

      if (str == NULL) {
        g_warning ("NULL string encountered");
        continue;
      }

      if (g_pattern_match_string (pattern, str)) {
        object_list = g_slist_prepend (object_list, object);
      }
    }
  }

  g_pattern_spec_free (pattern);

  return g_slist_reverse (object_list);
}
Example #12
0
void free_patterns(GPatternSpec **patterns)
{
        int i;
        if(patterns==NULL) {
                return;
        }
        for(i=0; patterns[i]!=NULL; i++) {
                g_pattern_spec_free(patterns[i]);
        }
        g_free(patterns);
}
Example #13
0
lfError lfDatabase::Load ()
{
    gchar *dirs [10];
    const gchar *const *tmp;
    int ndirs = 0;

    dirs [ndirs++] = HomeDataDir;
#ifdef CONF_DATADIR
    dirs [ndirs++] = (char *)CONF_DATADIR;
#else
    extern gchar *_lf_get_database_dir ();
    dirs [ndirs++] = _lf_get_database_dir ();
#endif
    int static_ndirs = ndirs;
    for (tmp = g_get_system_data_dirs (); ndirs < 10 && *tmp; tmp++)
        dirs [ndirs++] = g_build_filename (*tmp, CONF_PACKAGE, NULL);

    while (ndirs > 0)
    {
        ndirs--;
        GDir *dir = g_dir_open (dirs [ndirs], 0, NULL);

        if (dir)
        {
            GPatternSpec *ps = g_pattern_spec_new ("*.xml");
            if (ps)
            {
                const gchar *fn;
                while ((fn = g_dir_read_name (dir)))
                {
                    size_t sl = strlen (fn);
                    if (g_pattern_match (ps, sl, fn, NULL))
                    {
                        gchar *ffn = g_build_filename (dirs [ndirs], fn, NULL);
                        /* Ignore errors */
                        Load (ffn);
                        g_free (ffn);
                    }
                }
                g_pattern_spec_free (ps);
            }
            g_dir_close (dir);
        }

        /* Free all paths except the first one which is held in db struct */
        if (ndirs >= static_ndirs)
            g_free (dirs [ndirs]);
    }

    return LF_NO_ERROR;
}
Example #14
0
void
value_pairs_transform_set_free(ValuePairsTransformSet *vpts)
{
  GList *l;

  l = vpts->transforms;
  while (l)
    {
      value_pairs_transform_free((ValuePairsTransform *)l->data);
      l = g_list_delete_link(l, l);
    }
  g_pattern_spec_free(vpts->pattern);
  g_free(vpts);
}
Example #15
0
static void
gwy_app_recent_file_list_destroyed(Controls *controls)
{
    if (controls->pattern)
        g_pattern_spec_free(controls->pattern);
    controls->pattern = NULL;
    controls->window = NULL;
    controls->open = NULL;
    controls->prune = NULL;
    controls->list = NULL;
    controls->filter = NULL;
    controls->filter_glob = NULL;
    controls->filter_case = NULL;
}
Example #16
0
static void
filter_destroy(Tfilter * filter)
{
	GList *tmplist;
	g_free(filter->name);
	if (filter->filetypes)
		g_hash_table_destroy(filter->filetypes);
	for (tmplist = g_list_first(filter->patterns); tmplist; tmplist = g_list_next(tmplist)) {
		Tfilterpattern *pat = tmplist->data;
		g_pattern_spec_free(pat->patspec);
		g_free(pat->pattern);
	}
	g_list_free(filter->patterns);
	g_slice_free(Tfilter, filter);
}
Example #17
0
/**
 * g_pattern_match_simple:
 * @pattern: the UTF-8 encoded pattern
 * @string: the UTF-8 encoded string to match
 * @Returns: %TRUE if @string matches @pspec
 *
 * Matches a string against a pattern given as a string. If this
 * function is to be called in a loop, it's more efficient to compile
 * the pattern once with g_pattern_spec_new() and call
 * g_pattern_match_string() repeatedly.
 **/
gboolean
g_pattern_match_simple (const gchar *pattern,
			const gchar *string)
{
  GPatternSpec *pspec;
  gboolean ergo;

  g_return_val_if_fail (pattern != NULL, FALSE);
  g_return_val_if_fail (string != NULL, FALSE);

  pspec = g_pattern_spec_new (pattern);
  ergo = g_pattern_match (pspec, strlen (string), string, NULL);
  g_pattern_spec_free (pspec);

  return ergo;
}
Example #18
0
/**
 * Make messages matching $pat, a g_pattern expression appear as if
 * they were informational (#g_info()).  By configuring mafw-log you
 * can get rid of those messages from the program output.
 *
 * NOTE @pat is matched against the message format string, which may
 * or may not be what you need.
 */
void checkmore_ignore(gchar const *pat)
{
	if (pat != NULL) {
		if (!Msg_filters)
			Msg_filters = g_ptr_array_new();
		g_ptr_array_add(Msg_filters, g_pattern_spec_new(pat));
	} else if (Msg_filters)
	{
		guint i;

		/* Clear all ignores. */
		for (i = 0; i < Msg_filters->len; i++)
			g_pattern_spec_free(Msg_filters->pdata[i]);
		g_ptr_array_set_size(Msg_filters, 0);
	}
}
Example #19
0
/**
 * The function deallocate NULL terminate list of exclude patterns.
 *
 * \param patternList NULL terminated list of patterns
 */
void pile_exclude_destroy(GPatternSpec **patternList) {
	guint i;

	if ( NULL == patternList ) {
		return;
	}

	// free allocated patterns
	for ( i = 0; NULL != patternList[i] ; i++ ) {
		g_pattern_spec_free( patternList[i] );
	}

	// free allocated list
	g_free( (gpointer)patternList);

}
Example #20
0
/**
 * gtk_accel_map_add_filter:
 * @filter_pattern: a pattern (see #GPatternSpec)
 *
 * Adds a filter to the global list of accel path filters.
 *
 * Accel map entries whose accel path matches one of the filters
 * are skipped by gtk_accel_map_foreach().
 *
 * This function is intended for GTK+ modules that create their own
 * menus, but don’t want them to be saved into the applications accelerator
 * map dump.
 */
void
gtk_accel_map_add_filter (const gchar *filter_pattern)
{
  GPatternSpec *pspec;
  GSList *slist;

  g_return_if_fail (filter_pattern != NULL);

  pspec = g_pattern_spec_new (filter_pattern);
  for (slist = accel_filters; slist; slist = slist->next)
    if (g_pattern_spec_equal (pspec, slist->data))
      {
	g_pattern_spec_free (pspec);
	return;
      }
  accel_filters = g_slist_prepend (accel_filters, pspec);
}
Example #21
0
static GList *
remove_pattern_from_list(GList * list, const gchar * pattern)
{
	GList *tmplist = g_list_first(list);
	while (tmplist) {
		Tfilterpattern *pat = (Tfilterpattern *) tmplist->data;
		if (strcmp(pat->pattern, pattern) == 0) {
			g_free(pat->pattern);
			g_pattern_spec_free(pat->patspec);
			g_free(pat);
			list = g_list_delete_link(list, tmplist);
			return list;
		}

		tmplist = g_list_next(tmplist);
	}
	return list;
}
Example #22
0
void tokenize_free ( char ** tokens )
{
    if ( config.glob ) {
        for ( size_t i = 0; tokens && tokens[i]; i++ ) {
            g_pattern_spec_free ( (GPatternSpec *) tokens[i] );
        }
        g_free ( tokens );
    }
    else if ( config.regex ) {
        for ( size_t i = 0; tokens && tokens[i]; i++ ) {
            g_regex_unref ( (GRegex *) tokens[i] );
        }
        g_free ( tokens );
    }
    else {
        g_strfreev ( tokens );
    }
}
Example #23
0
static void
router_rule_destroy (RouterRule *rule)
{
  gint i;

  if (rule->destroy)
    (rule->destroy) (rule->user_data);
  for (i = 0; rule->matches && rule->matches[i].name != NULL; i++)
    {
      g_free (rule->matches[i].name);
      json_node_free (rule->matches[i].node);
      if (rule->matches[i].glob)
        g_pattern_spec_free (rule->matches[i].glob);
    }
  g_free (rule->matches);
  if (rule->config)
    json_object_unref (rule->config);
  g_free (rule);
}
Example #24
0
static void find_tags(const gchar *name, gboolean declaration, gboolean case_sensitive, MatchType match_type, gchar *utf8_path)
{
	gchar *utf8_base_path = get_project_base_path();
	gchar *locale_base_path = utils_get_locale_from_utf8(utf8_base_path);
	GPtrArray *tags_array = geany_data->app->tm_workspace->tags_array;
	guint i;
	gchar *name_case;
	GPatternSpec *pspec;

	if (case_sensitive)
		name_case = g_strdup(name);
	else
		name_case = g_utf8_strdown(name, -1);

	pspec = g_pattern_spec_new(name_case);

	msgwin_set_messages_dir(locale_base_path);
	msgwin_clear_tab(MSG_MESSAGE);
	for (i = 0; i < tags_array->len; i++) /* TODO: binary search */
	{
		TMTag *tag = tags_array->pdata[i];

		if (match(tag, name_case, declaration, case_sensitive, match_type, pspec, utf8_path))
		{
			gchar *scopestr = tag->scope ? g_strconcat(tag->scope, "::", NULL) : g_strdup("");
			gchar *utf8_fname = utils_get_utf8_from_locale(tag->file->file_name);
			gchar *relpath;

			relpath = get_relative_path(utf8_base_path, utf8_fname);
			msgwin_msg_add(COLOR_BLACK, -1, NULL, "%s:%lu:\n\t[%s]\t %s%s%s", relpath ? relpath : utf8_fname,
				tag->line, tm_tag_type_name(tag), scopestr, tag->name, tag->arglist ? tag->arglist : "");
			g_free(scopestr);
			g_free(relpath);
			g_free(utf8_fname);
		}
	}
	msgwin_switch_tab(MSG_MESSAGE, TRUE);

	g_free(name_case);
	g_pattern_spec_free(pspec);
	g_free(utf8_base_path);
	g_free(locale_base_path);
}
Example #25
0
static void
gwy_app_recent_file_list_filter_apply(GtkEntry *entry,
                                      Controls *controls)
{
    GPatternSpec *oldpattern;
    GwyContainer *settings;
    gchar *s, *t;

    settings = gwy_app_settings_get();
    g_string_assign(controls->glob, gtk_entry_get_text(entry));
    gwy_container_set_string_by_name(settings, "/app/file/recent/glob",
                                     g_strdup(controls->glob->str));

    oldpattern = controls->pattern;

    if (controls->casesens) {
        if (!strchr(controls->glob->str, '*')
            && !strchr(controls->glob->str, '?'))
            s = g_strconcat("*", controls->glob->str, "*", NULL);
        else
            s = g_strdup(controls->glob->str);
    }
    else {
        /* FIXME: This is crude. */
        s = g_utf8_strdown(controls->glob->str, controls->glob->len);
        if (!strchr(s, '*') && !strchr(s, '?')) {
            t = s;
            s = g_strconcat("*", t, "*", NULL);
            g_free(t);
        }
    }
    controls->pattern = g_pattern_spec_new(s);
    g_free(s);

    if (oldpattern)
        g_pattern_spec_free(oldpattern);

    if (GTK_WIDGET_REALIZED(controls->window))
        gwy_app_wait_cursor_start(GTK_WINDOW(controls->window));
    gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(controls->filter));
    if (GTK_WIDGET_REALIZED(controls->window))
        gwy_app_wait_cursor_finish(GTK_WINDOW(controls->window));
}
Example #26
0
static void engine_scan_dir(gchar * dir)
{
    GDir * d;
    d = g_dir_open(dir,0,NULL);
    if (d)
    {
        gchar * n;
        GPatternSpec * ps;
        ps = g_pattern_spec_new("lib*.so");
        while ((n = (gchar *) g_dir_read_name(d)))
        {
            if (g_pattern_match_string(ps,n))
            {
                gchar * dln = g_strjoin("/",dir,n,NULL);
                append_engine(dln);
            }
        }
        g_pattern_spec_free(ps);
        g_dir_close(d);
    }
}
static char *
find_file_with_pattern (const char *dir, const char *pattern)
{
	GDir *filedir;
	char *found_filename;
	const char *filename;
	GPatternSpec *pat;

	filedir = g_dir_open (dir, 0, NULL);
	if (filedir == NULL)
		return NULL;

	pat = g_pattern_spec_new (pattern);
	if (pat == NULL)
	{
		g_dir_close (filedir);
		return NULL;
	}

	found_filename = NULL;

	while ((filename = g_dir_read_name (filedir)))
	{
		if (g_pattern_match_string (pat, filename))
		{
			char *tmp = g_build_filename (dir, filename, NULL);
			if (is_owned_by_user_and_socket (tmp))
				found_filename = g_strdup (filename);
			g_free (tmp);
		}

		if (found_filename != NULL)
			break;
	}

	g_pattern_spec_free (pat);
	g_dir_close (filedir);

	return found_filename;
}
GList* get_files_by_pattern(const gchar* dirpath, FcitxSubConfigPattern* pattern, int index)
{
    GList* result = NULL;

    DIR* dir = opendir(dirpath);
    if (!dir)
        return result;

    gchar* filter = pattern->patternlist[index];

    struct dirent* drt;
    GPatternSpec * patternspec = g_pattern_spec_new(filter);
    while ((drt = readdir(dir)) != NULL) {
        if (strcmp(drt->d_name , ".") == 0 || strcmp(drt->d_name, "..") == 0)
            continue;

        if (!g_pattern_match_string(patternspec, drt->d_name))
            continue;

        if (pattern->patternlist[index + 1] == 0) {
            char *path;
            asprintf(&path, "%s/%s", dirpath, drt->d_name);
            struct stat statbuf;
            if (stat(path, &statbuf) == 0) {
                result = g_list_append(result, realpath(path, NULL));
            }
            free(path);
        } else {
            char *path;
            asprintf(&path, "%s/%s", dirpath, drt->d_name);
            GList* r = get_files_by_pattern(path, pattern, index + 1);
            result = g_list_concat(result, r);
            free(path);
        }
    }

    closedir(dir);
    g_pattern_spec_free(patternspec);
    return result;
}
Example #29
0
static void
mud_trigger_finalize (GObject *object)
{
    MudTrigger *self;
    GObjectClass *parent_class;

    self = MUD_TRIGGER(object);

    g_object_unref(self->priv->line_buffer);

    if(self->priv->regex)
        g_regex_unref(self->priv->regex);

    if(self->priv->glob)
        g_pattern_spec_free(self->priv->glob);

    g_free(self->priv->trigger_key);
    g_free(self->priv->profile_key);

    parent_class = g_type_class_peek_parent(G_OBJECT_GET_CLASS(object));
    parent_class->finalize(object);
}
Example #30
0
static void swap_clean (void)
{
  const gchar  *swap_dir = gegl_swap_dir ();
  GDir         *dir;

  if (! swap_dir)
    return;

  dir = g_dir_open (gegl_swap_dir (), 0, NULL);

  if (dir != NULL)
    {
      GPatternSpec *pattern = g_pattern_spec_new ("*");
      const gchar  *name;

      while ((name = g_dir_read_name (dir)) != NULL)
        {
          if (g_pattern_match_string (pattern, name))
            {
              gint readpid = atoi (name);

              if (!pid_is_running (readpid))
                {
                  gchar *fname = g_build_filename (gegl_swap_dir (),
                                                   name,
                                                   NULL);
                  g_unlink (fname);
                  g_free (fname);
                }
            }
         }

      g_pattern_spec_free (pattern);
      g_dir_close (dir);
    }
}