static void
gst_multi_file_sink_ensure_max_files (GstMultiFileSink * multifilesink)
{
  guint max_files = multifilesink->max_files;

  if (max_files == 0)
    return;

  while (g_queue_get_length (&multifilesink->old_files) >= max_files) {
    gchar *filename;

    filename = g_queue_pop_head (&multifilesink->old_files);
    g_remove (filename);
    g_free (filename);
  }
}
Beispiel #2
0
/**
 * a_babel_convert:
 * @vt:        The TRW layer to modify. All data will be deleted, and replaced by what gpsbabel outputs.
 * @babelargs: A string containing gpsbabel command line filter options. No file types or names should
 *             be specified.
 * @cb:        A callback function.
 * @user_data: passed along to cb
 * @not_used:  Must use NULL
 *
 * This function modifies data in a trw layer using gpsbabel filters.  This routine is synchronous;
 * that is, it will block the calling program until the conversion is done. To avoid blocking, call
 * this routine from a worker thread.
 *
 * Returns: %TRUE on success
 */
gboolean a_babel_convert( VikTrwLayer *vt, const char *babelargs, BabelStatusFunc cb, gpointer user_data, gpointer not_used )
{
  gboolean ret = FALSE;
  gchar *bargs = g_strconcat(babelargs, " -i gpx", NULL);
  gchar *name_src = a_gpx_write_tmp_file ( vt, NULL );

  if ( name_src ) {
    ProcessOptions po = { bargs, name_src, NULL, NULL, NULL };
    ret = a_babel_convert_from ( vt, &po, cb, user_data, not_used );
    (void)g_remove(name_src);
    g_free(name_src);
  }

  g_free(bargs);
  return ret;
}
Beispiel #3
0
static void _load_tile_thread(gpointer _tile, gpointer _sat)
{
	GritsTile      *tile = _tile;
	GritsPluginSat *sat  = _sat;

	g_debug("GritsPluginSat: _load_tile_thread start %p - tile=%p",
			g_thread_self(), tile);
	if (sat->aborted) {
		g_debug("GritsPluginSat: _load_tile_thread - aborted");
		return;
	}

	/* Download tile */
	gchar *path = grits_wms_fetch(sat->wms, tile, GRITS_ONCE, NULL, NULL);
	if (!path) return; // Canceled/error

	/* Load pixbuf */
	GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(path, NULL);
	if (!pixbuf) {
		g_warning("GritsPluginSat: _load_tile_thread - Error loading pixbuf %s", path);
		g_remove(path);
		g_free(path);
		return;
	}
	g_free(path);

	/* Draw a border */
#ifdef DRAW_TILE_BORDER
	gint    border = 10;
	gint    width  = gdk_pixbuf_get_width(pixbuf);
	gint    height = gdk_pixbuf_get_height(pixbuf);
	gint    stride = gdk_pixbuf_get_rowstride(pixbuf);
	guchar *pixels = gdk_pixbuf_get_pixels(pixbuf);
	for (int i = 0; i < border; i++) {
		memset(&pixels[(         i)*stride], 0xff, stride);
		memset(&pixels[(height-1-i)*stride], 0xff, stride);
	}
	for (int i = 0; i < height; i++) {
		memset(&pixels[(i*stride)                   ], 0xff, border*4);
		memset(&pixels[(i*stride)+((width-border)*4)], 0xff, border*4);
	}
#endif

	/* Load the GL texture from the main thread */
	grits_tile_load_pixbuf(tile, pixbuf);
	g_debug("GritsPluginSat: _load_tile_thread end %p", g_thread_self());
}
Beispiel #4
0
void rssyl_update_format()
{
	RUpdateFormatCtx *ctx = NULL;
	GSList *oldfeeds;
	gchar *old_feeds_xml = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
			RSSYL_DIR, G_DIR_SEPARATOR_S, "feeds.xml", NULL);

	if (!g_file_test(old_feeds_xml,
				G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
		g_free(old_feeds_xml);
		return;
	}

	debug_print("RSSyl: Old format found, updating.\n");

	oldfeeds = rssyl_old_feed_metadata_parse(old_feeds_xml);

	/* We find all rssyl root folders and perform magic on each */
	ctx = g_new0(RUpdateFormatCtx, 1);
	ctx->o_prev = NULL;
	ctx->o_parent = NULL;
	ctx->n_prev = NULL;
	ctx->n_parent = NULL;
	ctx->n_first = NULL;
	ctx->oldfeeds = oldfeeds;
	ctx->oldroots = NULL;
	ctx->reached_first_new = FALSE;

	folder_item_update_freeze();

	/* Go through all RSSyl folders, making new copies */
	folder_func_to_all_folders((FolderItemFunc)rssyl_update_format_func, ctx);

	g_slist_foreach(ctx->oldroots, _delete_old_roots_func, NULL);
	g_slist_free(ctx->oldroots);

	prefs_matcher_write_config();
	folder_write_list();

	folder_item_update_thaw();

	g_free(ctx);

	g_remove(old_feeds_xml);
	g_free(old_feeds_xml);
}
Beispiel #5
0
static void test_engine_ngspice_error_no_such_file_or_directory() {
	TestEngineNgspiceResources *test_resources = test_engine_ngspice_resources_new();

	// make sure that the given file does not exist
	g_free(test_resources->resources->netlist_file);
	gint fd = g_file_open_tmp(NULL, &test_resources->resources->netlist_file, NULL);
	g_close(fd, NULL);
	g_remove(test_resources->resources->netlist_file);

	ngspice_watcher_build_and_launch(test_resources->resources);
	g_main_loop_run(test_resources->loop);

	g_assert_nonnull(test_resources->log_list);
	g_assert_true(g_str_has_suffix(test_resources->log_list->data, " No such file or directory\n"));

	test_engine_ngspice_resources_finalize(test_resources);
}
static void
brasero_project_type_chooser_last_unsaved_clicked_cb (GtkButton *button,
						      BraseroProjectTypeChooser *self)
{
	const gchar *uri;
	gchar *path;

	uri = g_object_get_data (G_OBJECT (button), "BraseroButtonURI");
	path = g_filename_from_uri (uri, NULL, NULL);

	g_signal_emit (self,
		       brasero_project_type_chooser_signals [LAST_SAVED_CLICKED_SIGNAL],
		       0,
		       path);

	g_remove (path);
	g_free (path);
}
Beispiel #7
0
gboolean
delete_if_exists(gchar* path){
  if(g_file_test(path, G_FILE_TEST_EXISTS)){
    if(g_file_test(path, G_FILE_TEST_IS_DIR)){
      GError *error = NULL;
      GDir* dir = g_dir_open(path, 0, &error);
      gchar* filename = NULL;
      gchar* child = NULL;
      while (filename = g_dir_read_name(dir)){
        child = g_build_filename(path, filename, NULL);
        delete_if_exists(child);
        g_free(child);
      }
   }
   if(g_remove(path) < 0)
     g_warning("Could not remove %s", path);
  }
}
Beispiel #8
0
void filesystem::g_copy(const char * src,const char * dst,abort_callback & p_abort) {
	service_ptr_t<file> r_src,r_dst;
	t_filesize size;

	g_open(r_src,src,open_mode_read,p_abort);
	size = r_src->get_size_ex(p_abort);
	g_open(r_dst,dst,open_mode_write_new,p_abort);
	
	if (size > 0) {
		try {
			file::g_transfer_object(r_src,r_dst,size,p_abort);
		} catch(...) {
			r_dst.release();
			try {g_remove(dst,abort_callback_dummy());} catch(...) {}
			throw;
		}
	}
}
Beispiel #9
0
static gchar *
generate_control_path (FlowSshMaster *ssh_master)
{
  gchar *cache_dir;
  gchar *path;

  cache_dir = g_strdup_printf ("%s/flow", g_get_user_cache_dir ());
  g_mkdir_with_parents (cache_dir, 0770);

  path = g_strdup_printf ("%s/ssh-master-%d-%016" G_GINT64_MODIFIER "x",
                          cache_dir,
                          getpid (),
                          (guint64) ssh_master);
  g_remove (path);

  g_free (cache_dir);
  return path;
}
static void
on_delete_clicked (GtkButton * button, gpointer user_data)
{
  BtCrashRecoverDialog *self = BT_CRASH_RECOVER_DIALOG (user_data);
  gchar *log_name = get_selected (self);

  if (log_name) {
    if (g_remove (log_name)) {
      GST_WARNING ("failed removing '%s': %s", log_name, g_strerror (errno));
    }
    remove_selected (self);
    g_free (log_name);
    /* if that was the last entry, close dialog */
    if (!check_selection (self, NULL, NULL)) {
      gtk_dialog_response (GTK_DIALOG (self), GTK_RESPONSE_CLOSE);
    }
  }
}
Beispiel #11
0
gboolean utility_removeAll(const gchar* path) {
    if(!path || !g_file_test(path, G_FILE_TEST_EXISTS)) {
        return FALSE;
    }

    gboolean isSuccess = TRUE;

    /* directories must be empty before we can remove them */
    if(g_file_test(path, G_FILE_TEST_IS_DIR)) {
        /* recurse into this directory and remove all files */
        GError* err = NULL;
        GDir* dir = g_dir_open(path, 0, &err);

        if(err) {
            warning("unable to open directory '%s': error %i: %s", path, err->code, err->message);
            isSuccess = FALSE;
            g_error_free(err);
        } else {
            const gchar* entry = NULL;
            while((entry = g_dir_read_name(dir)) != NULL) {
                gchar* childPath = g_build_filename(path, entry, NULL);
                gboolean childSuccess = utility_removeAll(childPath);
                g_free(childPath);
                if(!childSuccess) {
                    isSuccess = FALSE;
                    break;
                }
            }

            g_dir_close(dir);
        }
    }

    /* now remove the empty directory, or the file */
    if(g_remove(path) != 0) {
        warning("unable to remove path '%s': error %i: %s", path, errno, strerror(errno));
        isSuccess = FALSE;
    } else {
        info("removed path '%s' from filesystem", path);
        isSuccess = TRUE;
    }

    return isSuccess;
}
Beispiel #12
0
int
main (int argc, char **argv)
{
	gchar *current_dir;
	gint result;
	gint i;

	/* Warning warning!!! We need to impose a proper LC_COLLATE here, so
	 * that the expected order in the test results is always the same! */
	setlocale (LC_COLLATE, "en_US.utf8");

	current_dir = g_get_current_dir ();
	tests_data_dir = g_build_path (G_DIR_SEPARATOR_S, current_dir, "test-data", NULL);
	g_free (current_dir);

	g_test_init (&argc, &argv, NULL);

	/* add test cases */
	g_test_add ("/libtracker-data/ontology-init", TestInfo, GINT_TO_POINTER(0), setup_all_others, test_ontology_init, teardown);

	for (i = 0; nie_tests[i].test_name; i++) {
		gchar *testpath;

		testpath = g_strconcat ("/libtracker-data/nie/", nie_tests[i].test_name, NULL);
		g_test_add (testpath, TestInfo, GINT_TO_POINTER(i), setup_nie, test_query, teardown);
		g_free (testpath);
	}

	for (i = 0; nmo_tests[i].test_name; i++) {
		gchar *testpath;

		testpath = g_strconcat ("/libtracker-data/nmo/", nmo_tests[i].test_name, NULL);
		g_test_add (testpath, TestInfo, GINT_TO_POINTER(i), setup_nmo, test_query, teardown);
		g_free (testpath);
	}

	/* run tests */
	result = g_test_run ();

	g_remove (tests_data_dir);
	g_free (tests_data_dir);

	return result;
}
Beispiel #13
0
static int geonames_search_get_coord(VikWindow *vw, VikViewport *vvp, gchar *srch_str, VikCoord *coord)
{
  gchar *uri;
  gchar *escaped_srch_str;
  int ret = 1;  /* OK */
  struct LatLon ll;
  gchar *tmpname;

  g_debug("%s: raw search: %s", __FUNCTION__, srch_str);
  escaped_srch_str = uri_escape(srch_str);
  g_debug("%s: escaped search: %s", __FUNCTION__, escaped_srch_str);

  //uri = g_strdup_printf(GEONAMES_SEARCH_URL_FMT, srch_str);
  uri = g_strdup_printf(GEONAMES_SEARCH_URL_FMT, escaped_srch_str);

  tmpname = download_url(uri);
  if (!tmpname) {
    ret = -1;
    goto done;
  }
  ret = parse_file_for_latlon(vw, tmpname, &ll);
  if (ret == 3) {
    goto done;
  }

  vik_coord_load_from_latlon ( coord, vik_viewport_get_coord_mode(vvp), &ll );

  if (last_coord)
    g_free(last_coord);
  last_coord = g_malloc(sizeof(VikCoord));
  *last_coord = *coord;
  if (last_successful_search_str)
    g_free(last_successful_search_str);
  last_successful_search_str = g_strdup(last_search_str);

done:
  g_free(escaped_srch_str);
  g_free(uri);
  if (tmpname) {
    g_remove(tmpname);
    g_free(tmpname);
  }
  return ret;
}
Beispiel #14
0
/**
 * a_babel_convert_from:
 * @vt:        The TRW layer to place data into. Duplicate items will be overwritten.
 * @babelargs: A string containing gpsbabel command line options. In addition to any filters, this string
 *             must include the input file type (-i) option.
 * @cb:	       Optional callback function. Same usage as in a_babel_convert().
 * @user_data: passed along to cb
 * @not_used:  Must use NULL
 *
 * Loads data into a trw layer from a file, using gpsbabel.  This routine is synchronous;
 * that is, it will block the calling program until the conversion is done. To avoid blocking, call
 * this routine from a worker thread.
 *
 * Returns: %TRUE on success
 */
gboolean a_babel_convert_from( VikTrwLayer *vt, const char *babelargs, const char *from, BabelStatusFunc cb, gpointer user_data, gpointer not_used )
{
  int i,j;
  int fd_dst;
  gchar *name_dst = NULL;
  gboolean ret = FALSE;
  gchar *args[64];

  if ((fd_dst = g_file_open_tmp("tmp-viking.XXXXXX", &name_dst, NULL)) >= 0) {
    g_debug ("%s: temporary file: %s", __FUNCTION__, name_dst);
    close(fd_dst);

    if (gpsbabel_loc ) {
      gchar **sub_args = g_strsplit(babelargs, " ", 0);

      i = 0;
      if (unbuffer_loc)
        args[i++] = unbuffer_loc;
      args[i++] = gpsbabel_loc;
      for (j = 0; sub_args[j]; j++) {
        /* some version of gpsbabel can not take extra blank arg */
        if (sub_args[j][0] != '\0')
          args[i++] = sub_args[j];
      }
      args[i++] = "-o";
      args[i++] = "gpx";
      args[i++] = "-f";
      args[i++] = (char *)from;
      args[i++] = "-F";
      args[i++] = name_dst;
      args[i] = NULL;

      ret = babel_general_convert_from ( vt, cb, args, name_dst, user_data );

      g_strfreev(sub_args);
    } else
      g_critical("gpsbabel not found in PATH");
    g_remove(name_dst);
    g_free(name_dst);
  }

  return ret;
}
Beispiel #15
0
void
deinit_upnp (void)
{
        g_object_unref (context_manager);

        g_hash_table_unref (nl_hash);

        g_list_foreach (switch_proxies, (GFunc) g_object_unref, NULL);
        g_list_foreach (dimming_proxies, (GFunc) g_object_unref, NULL);

        /* Unref the descriptiont doc */
        g_object_unref (doc);

        if (g_remove (desc_location) != 0)
                g_warning ("error removing %s\n", desc_location);
        g_free (desc_location);
        g_free (uuid);
        uuid = NULL;
}
Beispiel #16
0
/**
 * asb_utils_rmtree:
 * @directory: utf8 directory name
 * @error: A #GError or %NULL
 *
 * Removes a directory tree.
 *
 * Returns: %TRUE for success, %FALSE otherwise
 *
 * Since: 0.1.0
 **/
gboolean
asb_utils_rmtree (const gchar *directory, GError **error)
{
	gint rc;
	gboolean ret;

	ret = asb_utils_ensure_exists_and_empty (directory, error);
	if (!ret)
		return FALSE;
	rc = g_remove (directory);
	if (rc != 0) {
		g_set_error (error,
			     ASB_PLUGIN_ERROR,
			     ASB_PLUGIN_ERROR_FAILED,
			     "Failed to delete: %s", directory);
		return FALSE;
	}
	return TRUE;
}
Beispiel #17
0
static void dvr_clean (Gstreamill *gstreamill)
{
        guint64 now, time;
        gint i, j;
        gchar *pattern;
        glob_t pglob;
        GSList *list;
        Job *job;

        now = g_get_real_time ();
        if (now - gstreamill->last_dvr_clean_time < 600000000) {
                return;
        }

        list = gstreamill->job_list;
        while (list != NULL) {
                job = list->data;
                /* non live job need not clean dvr */
                if (!job->is_live) {
                        list = list->next;
                        continue;
                }
                for (i = 0; i < job->output->encoder_count; i++) {
                        if (job->output->encoders[i].record_path == NULL) {
                                continue;
                        }
                        time = (now / 1000000 - job->output->encoders[i].dvr_duration) / 10;
                        while (time > 11) {
                                pattern = g_strdup_printf ("%s/%lu*.ts", job->output->encoders[i].record_path, time - 1);
                                GST_ERROR ("%s", pattern);
                                glob (pattern, 0, NULL, &pglob);
                                for (j = 0; j < pglob.gl_pathc; j++) {
                                        g_remove (pglob.gl_pathv[j]);
                                }
                                globfree (&pglob);
                                g_free (pattern);
                                time = time / 10;
                        }
                }
                list = list->next;
        }
        gstreamill->last_dvr_clean_time = now;
}
Beispiel #18
0
int
main (int argc, char **argv)
{
	gchar *current_dir;
	gint result;
	gint i;

	setlocale (LC_COLLATE, "en_US.utf8");

	current_dir = g_get_current_dir ();
	tests_data_dir = g_build_path (G_DIR_SEPARATOR_S, current_dir, "test-data", NULL);
	g_free (current_dir);

	g_test_init (&argc, &argv, NULL);

	/* add test cases */
	for (i = 0; tests[i].test_name; i++) {
		gchar *testpath;

#ifndef HAVE_LIBICU
		/* Skip tests which fail collation tests and are known
		 * to do so. For more details see:
		 *
		 * https://bugzilla.gnome.org/show_bug.cgi?id=636074
		 */
		if (strcmp (tests[i].test_name, "functions/functions-xpath-2") == 0) {
			continue;
		}
#endif

		testpath = g_strconcat ("/libtracker-data/sparql/", tests[i].test_name, NULL);
		g_test_add (testpath, TestInfo, GINT_TO_POINTER(i), setup, test_sparql_query, teardown);
		g_free (testpath);
	}

	/* run tests */
	result = g_test_run ();

	g_remove (tests_data_dir);
	g_free (tests_data_dir);

	return result;
}
Beispiel #19
0
/*
 * Delete empty directory @path, with a retry loop if the system call is
 * interrupted by an async signal. If @path does not exist, ignore.
 */
void
test_rmdir_if_exists (const gchar *path)
{
  while (g_remove (path) != 0)
    {
      int saved_errno = errno;

      if (saved_errno == ENOENT)
        return;

#ifdef G_OS_UNIX
      if (saved_errno == EINTR)
        continue;
#endif

      g_error ("Unable to remove directory \"%s\": %s", path,
               g_strerror (saved_errno));
    }
}
Beispiel #20
0
static BraseroBurnResult
brasero_cdrecord_post (BraseroJob *job)
{
	BraseroCDRecordPrivate *priv;
	GSList *iter;

	priv = BRASERO_CD_RECORD_PRIVATE (job);
	for (iter = priv->infs; iter; iter = iter->next) {
		gchar *path;

		path = iter->data;
		g_remove (path);
		g_free (path);
	}

	g_slist_free (priv->infs);
	priv->infs = NULL;

	return brasero_job_finished_session (job);
}
Beispiel #21
0
int latex_remove_auxfile(GuEditor* ec)
{
  gchar* auxfile = NULL;
  int res = -1;
  // TODO: merge this into function with several other instances.
  // for instance the lines in analyse_log
  if (ec->filename == NULL) {
    auxfile = g_strconcat(ec->basename, ".aux", NULL);
  } else {
    auxfile = g_strconcat(C_TMPDIR, C_DIRSEP,
                          g_path_get_basename(ec->basename), ".aux", NULL);
  }

  // TODO: extend for other build files
  if (g_file_test(auxfile, G_FILE_TEST_EXISTS)) {
    res = g_remove(auxfile);
  }
  g_free(auxfile);
  return res;
}
Beispiel #22
0
gint saveIndividual(individual* program, gchar* filename){
	if(!filename) g_printf("Function saveIndividual(): filename is not valid.\n");
	//g_printf("Saving individual %s (address: %x)\n", filename, program);
	if(!program){
		g_printf("function saveIndividual(): *program is not valid.");
		return 0;
	}
	if(g_file_test(filename, G_FILE_TEST_EXISTS)){
		if(g_remove(filename)!=0){
			g_printf("remove outdated file failed.");
			return 0;
		}
	}
	gchar* cmd=g_malloc0(512*sizeof(gchar));
	if(program==ori){
		g_snprintf(cmd, 512, "gcc %s -shared -fPIC -o %s -O3 malloc.c", GCC_M32, filename);
	}
	else{
		g_snprintf(cmd, 512, "gcc %s -shared -fPIC -o %s -O3 malloc.c -D\'MALLOC_ALIGNMENT=((size_t)(%d*sizeof(void*)))\' -DFOOTERS=%d -DINSECURE=%d -DNO_SEGMENT_TRAVERSAL=%d -DMORECORE_CONTIGUOUS=%d -DDEFAULT_GRANULARITY=%d -DDEFAULT_TRIM_THRESHOLD=%d -DDEFAULT_MMAP_THRESHOLD=%d -DMAX_RELEASE_CHECK_RATE=%d -DTOP_FOOT_SIZE=%d -DLINE4114=%d -DLINE4353=%d -DLINE4059=%d", GCC_M32, filename,
			program->chrom[0],
			(program->chrom[1] & FOOTER_BIT)==0? 0:1,
			(program->chrom[1] & INSECURE_BIT)==0? 0:1,
			(program->chrom[1] & NO_SEGMENT_TRAVERSAL_BIT)==0? 0:1,
			(program->chrom[1] & MORECORE_CONTIGUOUS_BIT)==0? 0:1,
			program->chrom[2]*1024,
			program->chrom[3]*1024,
			program->chrom[4]*1024,
			program->chrom[5],
			program->chrom[6],
			program->chrom[7],
			program->chrom[8],
			program->chrom[9]);
	}
	//g_spawn_command_line_sync(cmd, NULL, NULL, NULL, NULL);
	system(cmd);
	g_free(cmd);
	if(!g_file_test(filename, G_FILE_TEST_EXISTS)){
		return 0;
	}
	return 1;
}
Beispiel #23
0
static void latest_version_thread ( GtkWindow *window )
{
	// Need to allow a few redirects, as SF file is often served from different server
	DownloadMapOptions options = { FALSE, FALSE, NULL, 5, NULL, NULL, NULL };
	gchar *filename = a_download_uri_to_tmp_file ( "http://sourceforge.net/projects/viking/files/VERSION", &options );
	//gchar *filename = g_strdup ( "VERSION" );
	if ( !filename ) {
		return;
	}

	GMappedFile *mf = g_mapped_file_new ( filename, FALSE, NULL );
	if ( !mf )
		return;

	gchar *text = g_mapped_file_get_contents ( mf );

	gint latest_version = viking_version_to_number ( text );
	gint my_version = viking_version_to_number ( VIKING_VERSION );

	g_debug ( "The lastest version is: %s", text );

	if ( my_version < latest_version ) {
		new_version_thread_data *nvtd = g_malloc ( sizeof(new_version_thread_data) );
		nvtd->window = window;
		nvtd->version = g_strdup ( text );
		gdk_threads_add_idle ( (GSourceFunc) new_version_available_message, nvtd );
	}
	else
		g_debug ( "Running the lastest version: %s", VIKING_VERSION );

	g_mapped_file_unref ( mf );
	if ( filename ) {
		g_remove ( filename );
		g_free ( filename );
	}

	// Update last checked time
	GTimeVal time;
	g_get_current_time ( &time );
	a_settings_set_string ( VIK_SETTINGS_VERSION_CHECKED_DATE, g_time_val_to_iso8601(&time) );
}
static void
idol_disc_recorder_plugin_burn (GtkAction *action,
				 IdolDiscRecorderPlugin *pi)
{
	char *path;
	char *error = NULL;

	path = idol_disc_recorder_plugin_write_video_project (pi, &error);
	if (!path) {
		idol_interface_error (_("The movie could not be recorded."),
				       error,
				       idol_get_main_window (pi->idol));
		g_free (error);
		return;
	}

	if (!idol_disc_recorder_plugin_start_burning (pi, path, FALSE))
		g_remove (path);

	g_free (path);
}
Beispiel #25
0
static void
brasero_cdrecord_finalize (GObject *object)
{
	BraseroCDRecordPrivate *priv;
	GSList *iter;

	priv = BRASERO_CD_RECORD_PRIVATE (object);

	for (iter = priv->infs; iter; iter = iter->next) {
		gchar *path;

		path = iter->data;
		g_remove (path);
		g_free (path);
	}

	g_slist_free (priv->infs);
	priv->infs = NULL;

	G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
xplayer_disc_recorder_plugin_burn (GtkAction *action,
				 XplayerDiscRecorderPlugin *pi)
{
	char *path;
	char *error = NULL;

	path = xplayer_disc_recorder_plugin_write_video_project (pi, &error);
	if (!path) {
		xplayer_interface_error (_("The movie could not be recorded."),
				       error,
				       xplayer_get_main_window (pi->priv->xplayer));
		g_free (error);
		return;
	}

	if (!xplayer_disc_recorder_plugin_start_burning (pi, path, FALSE))
		g_remove (path);

	g_free (path);
}
Beispiel #27
0
static void cleancache_r(gchar *path)
{
	GDir *dir = g_dir_open(path, 0, NULL);
	if (!dir)
		return;
	const gchar *child;
	while ((child = g_dir_read_name(dir))) {
		gchar *child_path = g_build_filename(path, child, NULL);
		if (g_file_test(child_path, G_FILE_TEST_IS_DIR)) {
			cleancache_r(child_path);
		} else {
			struct stat st;
			g_stat(child_path, &st);
			if (st.st_atime < time(NULL)-60*60*24)
				g_remove(child_path);
		}
		g_free(child_path);
	}
	g_dir_close(dir);
	g_rmdir(path);
}
Beispiel #28
0
/*
 * ai_utils_directory_remove:
 *
 * Removes the contents of a directory, but not the directory itself
 */
static gboolean
ai_utils_directory_remove_contents (const gchar *directory)
{
	gboolean ret = FALSE;
	GDir *dir;
	GError *error = NULL;
	const gchar *filename;
	gchar *src;
	gint retval;

	/* try to open */
	dir = g_dir_open (directory, 0, &error);
	if (dir == NULL) {
		g_warning ("cannot open directory: %s", error->message);
		g_error_free (error);
		goto out;
	}

	/* find each */
	while ((filename = g_dir_read_name (dir))) {
		src = g_build_filename (directory, filename, NULL);
		ret = g_file_test (src, G_FILE_TEST_IS_DIR);
		if (ret) {
			/* recurse */
			ai_utils_directory_remove_contents (src);
			retval = g_remove (src);
			if (retval != 0)
				g_warning ("failed to delete %s", src);
		} else {
			retval = g_unlink (src);
			if (retval != 0)
				g_warning ("failed to delete %s", src);
		}
		g_free (src);
	}
	g_dir_close (dir);
	ret = TRUE;
out:
	return ret;
}
Beispiel #29
0
sc_bool sc_fs_storage_write_to_path(sc_segment **segments)
{
    sc_uint idx = 0;
    const sc_segment *segment = 0;
    gchar file_name[MAX_PATH_LENGTH + 1];
    gchar segments_path[MAX_PATH_LENGTH + 1];

    if (!g_file_test(repo_path, G_FILE_TEST_IS_DIR))
    {
        g_error("%s isn't a directory.", repo_path);
        return SC_FALSE;
    }

    // check if segments directory exists, if it doesn't, then create one
    g_snprintf(segments_path, MAX_PATH_LENGTH, "%s/%s", repo_path, seg_dir);
    if (!g_file_test(segments_path, G_FILE_TEST_IS_DIR))
    {
        if (g_mkdir_with_parents(segments_path, SC_DIR_PERMISSIONS) < 0)
            return SC_FALSE;
    }

    for (idx = 0; idx < SC_ADDR_SEG_MAX; idx++)
    {
        segment = segments[idx];
        if (segment == nullptr) continue; // skip null segments

        _get_segment_path(segments_path, idx, MAX_PATH_LENGTH, file_name);
        g_file_set_contents(file_name, (gchar*)segment, sizeof(sc_segment), 0);
    }

    _get_segment_path(segments_path, idx, MAX_PATH_LENGTH, file_name);
    while (g_file_test(file_name, G_FILE_TEST_EXISTS))
    {
        g_remove(file_name);
        _get_segment_path(segments_path, ++idx, MAX_PATH_LENGTH, file_name);
    }


    return SC_TRUE;
}
void
set_user_icon_data (ActUser   *user,
                    GdkPixbuf *pixbuf)
{
        gchar *path;
        gint fd;
        GOutputStream *stream;
        GError *error;

        path = g_build_filename (g_get_tmp_dir (), "gnome-control-center-user-icon-XXXXXX", NULL);
        fd = g_mkstemp (path);

        if (fd == -1) {
                g_warning ("failed to create temporary file for image data");
                g_free (path);
                return;
        }

        stream = g_unix_output_stream_new (fd, TRUE);

        error = NULL;
        if (!gdk_pixbuf_save_to_stream (pixbuf, stream, "png", NULL, &error, NULL)) {
                g_warning ("failed to save image: %s", error->message);
                g_error_free (error);
                g_object_unref (stream);
                return;
        }

        g_object_unref (stream);

        act_user_set_icon_file (user, path);

        /* if we ever make the dbus call async, the g_remove call needs
         * to wait for its completion
         */
        g_remove (path);

        g_free (path);
}