Beispiel #1
0
/**
 * e_path_rmdir:
 * @prefix: a prefix to prepend to the path, or %NULL
 * @path: the virtual path to convert to a filesystem path.
 *
 * This removes the directory pointed to by @prefix and @path
 * and attempts to remove its parent "subfolders" directory too
 * if it's empty.
 *
 * Return value: -1 (with errno set) if it failed to rmdir the
 * specified directory. 0 otherwise, whether or not it removed
 * the parent directory.
 **/
gint
e_path_rmdir (const gchar *prefix,
              const gchar *vpath)
{
	gchar *physical_path, *p;

	/* Remove the directory itself */
	physical_path = e_path_to_physical (prefix, vpath);
	if (g_rmdir (physical_path) == -1) {
		g_free (physical_path);
		return -1;
	}

	/* Attempt to remove its parent "subfolders" directory,
	 * ignoring errors since it might not be empty.
	 */

	p = strrchr (physical_path, '/');
	if (p[1] == '\0') {
		g_free (physical_path);
		return 0;
	}
	*p = '\0';
	p = strrchr (physical_path, '/');
	if (!p || strcmp (p + 1, SUBFOLDER_DIR_NAME) != 0) {
		g_free (physical_path);
		return 0;
	}

	g_rmdir (physical_path);
	g_free (physical_path);
	return 0;
}
Beispiel #2
0
int main(int argc, char **argv)
{
    int ret;
    TestState ts = { 0 };

    ts.src_tpm_path = g_dir_make_tmp("qemu-tpm-tis-swtpm-test.XXXXXX", NULL);
    ts.dst_tpm_path = g_dir_make_tmp("qemu-tpm-tis-swtpm-test.XXXXXX", NULL);
    ts.uri = g_strdup_printf("unix:%s/migsocket", ts.src_tpm_path);

    module_call_init(MODULE_INIT_QOM);
    g_test_init(&argc, &argv, NULL);

    qtest_add_data_func("/tpm/tis-swtpm/test", &ts, tpm_tis_swtpm_test);
    qtest_add_data_func("/tpm/tis-swtpm-migration/test", &ts,
                        tpm_tis_swtpm_migration_test);
    ret = g_test_run();

    g_rmdir(ts.dst_tpm_path);
    g_free(ts.dst_tpm_path);
    g_rmdir(ts.src_tpm_path);
    g_free(ts.src_tpm_path);
    g_free(ts.uri);

    return ret;
}
static void
delete_all (TestCase *tc)
{
  GDir *dir = NULL;
  GError *error = NULL;
  gchar *parent = NULL;
  const gchar *name;

  dir = g_dir_open (tc->cert_dir, 0, &error);
  if (!dir)
    goto out;

  while ((name = g_dir_read_name (dir)) != NULL)
    {
      gchar *path = g_build_filename (tc->cert_dir, name, NULL);
      g_unlink (path);
      g_free (path);
    }

  g_rmdir (tc->cert_dir);
  parent = g_path_get_dirname (tc->cert_dir);
  g_rmdir (parent);
  g_rmdir (config_dir);

out:
  if (dir)
    g_dir_close (dir);
  g_clear_error (&error);
  g_free (parent);
}
Beispiel #4
0
int
seaf_remove_empty_dir (const char *path)
{
    SeafStat st;
    char *ds_store, *thumbs_db;

    if (seaf_stat (path, &st) < 0 || !S_ISDIR(st.st_mode))
        return 0;

    if (g_rmdir (path) < 0) {
        ds_store = g_build_filename (path, ".DS_Store", NULL);
        g_unlink (ds_store);
        g_free (ds_store);

        thumbs_db = g_build_filename (path, "Thumbs.db", NULL);
        g_unlink (thumbs_db);
        g_free (thumbs_db);

        if (g_rmdir (path) < 0) {
            return -1;
        }
    }

    return 0;
}
Beispiel #5
0
static int
remove_path (const char *worktree, const char *name, unsigned int ctime, unsigned int mtime)
{
    char *slash;
    char *path;
    SeafStat st;

    path = g_build_path(PATH_SEPERATOR, worktree, name, NULL);

    /* file doesn't exist in work tree */
    if (seaf_stat (path, &st) < 0) {
        g_free (path);
        return 0;
    }

    if (S_ISREG (st.st_mode)) {
        /* file has been changed. */
        if (ctime != st.st_ctime || mtime != st.st_mtime) {
            g_free (path);
            return 0;
        }

        if (g_unlink(path) && errno != ENOENT) {
            g_free (path);
            return -1;
        }
    } else if (S_ISDIR (st.st_mode)) {
        if (g_rmdir (path) < 0) {
            g_free (path);
            return -1;
        }
    } else {
        g_free (path);
        return 0;
    }

    slash = strrchr (path, '/');
    if (slash) {
        do {
            *slash = '\0';
        } while (strcmp (worktree, path) != 0 &&
                 g_rmdir (path) == 0 &&
                 (slash = strrchr (path, '/')));
    }

    g_free (path);
    return 0;
}
Beispiel #6
0
static int
rmdir_real (GString *path)
{
	const gchar *dirname;
	struct stat st;
	size_t len;
	GDir *dir;
	
	if (!(dir = g_dir_open (path->str, 0, NULL)))
		return -1;
	
	g_string_append_c (path, G_DIR_SEPARATOR);
	len = path->len;
	
	while ((dirname = g_dir_read_name (dir))) {
		if (!strcmp (dirname, ".") || !strcmp (dirname, ".."))
			continue;
		
		g_string_truncate (path, len);
		g_string_append (path, dirname);
		
		if (g_lstat (path->str, &st) == 0 && S_ISDIR (st.st_mode))
			rmdir_real (path);
		else
			g_unlink (path->str);
	}
	
	g_dir_close (dir);
	
	g_string_truncate (path, len - 1);
	
	return g_rmdir (path->str);
}
Beispiel #7
0
/* Delete a directory recursively. */
void
rmdir_recursive    (gchar *path)
{
  GDir *cur_dir;
  const gchar *dir_file;
			
  cur_dir = g_dir_open (path, 0, NULL);

  if (cur_dir)
    {
      while ( (dir_file = g_dir_read_name (cur_dir)))
        {
          gchar *fpath = g_build_filename (path, dir_file, NULL);

          if (fpath)
            {
              if (g_file_test (fpath, G_FILE_TEST_IS_DIR))
                {
                  rmdir_recursive (fpath);
                }
              else
                {
                  g_unlink (fpath);
                }
              g_free (fpath);
            }
        }
			
      g_dir_close (cur_dir);
    }

  g_rmdir (path);
}
static void
groupwise_forget_folder (CamelGroupwiseStore *gw_store, const gchar *folder_name, GError **error)
{
	CamelGroupwiseStorePrivate *priv = gw_store->priv;
	gchar *state_file;
	gchar *folder_dir, *storage_path;
	CamelFolderInfo *fi;

	storage_path = g_strdup_printf ("%s/folders", priv->storage_path);
	folder_dir = e_path_to_physical (storage_path,folder_name);

	if (g_access (folder_dir, F_OK) != 0) {
		g_free (folder_dir);
		return;
	}

	state_file = g_strdup_printf ("%s/cmeta", folder_dir);
	g_unlink (state_file);
	g_free (state_file);

	g_rmdir (folder_dir);
	g_free (folder_dir);

	camel_store_summary_remove_path ( (CamelStoreSummary *)gw_store->summary, folder_name);
	camel_store_summary_save ( (CamelStoreSummary *)gw_store->summary);

	fi = groupwise_build_folder_info (gw_store, NULL, folder_name);
	camel_store_folder_deleted (CAMEL_STORE (gw_store), fi);
	camel_folder_info_free (fi);
}
Beispiel #9
0
gboolean
bench_utils_remove_path(const gchar *path, GError **error)
{
  if (!g_file_test(path, G_FILE_TEST_EXISTS)) {
    g_set_error(error, G_FILE_ERROR, G_FILE_ERROR_NOENT,
                "path doesn't exist: %s", path);
    return FALSE;
  }

  if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
    if (g_rmdir(path) == -1) {
      g_set_error(error, G_FILE_ERROR, g_file_error_from_errno(errno),
                  "can't remove directory: %s", path);
      return FALSE;
    }
  } else {
    if (g_unlink(path) == -1) {
      g_set_error(error, G_FILE_ERROR, g_file_error_from_errno(errno),
                  "can't remove path: %s", path);
      return FALSE;
    }
  }

  return TRUE;
}
Beispiel #10
0
void _remove_dir(gchar const * path)
{
    char tmp_path[MAX_PATH_LENGTH];
    gchar const * fname = 0;
    GDir * dir = 0;

    if (g_file_test(path, G_FILE_TEST_IS_DIR) == FALSE)
        return;

    dir = g_dir_open(path, 0, 0);
    g_assert( dir != (GDir*)0 );

    // calculate files
    fname = g_dir_read_name(dir);
    while (fname != 0)
    {
        g_snprintf(tmp_path, MAX_PATH_LENGTH, "%s/%s", path, fname);

        if (g_file_test(tmp_path, G_FILE_TEST_IS_REGULAR) == TRUE)
        {
            if (g_remove(tmp_path) == -1)
                g_critical("Can't remove file: %s", tmp_path);
        }
        else if (g_file_test(tmp_path, G_FILE_TEST_IS_DIR) == TRUE)
        {
            _remove_dir(tmp_path);
        }

        fname = g_dir_read_name(dir);
    }

    g_dir_close(dir);
    g_rmdir(path);
}
Beispiel #11
0
void
scalix_recursive_delete (const char *path)
{
    GDir *dh;
    const char *name;

    if (!g_file_test (path, G_FILE_TEST_IS_DIR)) {
        g_unlink (path);
        return;
    }

    dh = g_dir_open (path, 0, NULL);

    while ((name = g_dir_read_name (dh))) {
        char *fp;

        if (g_str_equal (name, ".") || g_str_equal (name, "..")) {
            continue;
        }

        fp = g_build_filename (path, name, NULL);
        scalix_recursive_delete (fp);
        g_free (fp);
    }

    if (dh != NULL) {
        g_dir_close (dh);
    }

    g_rmdir (path);
}
Beispiel #12
0
gboolean r_umount_slot(RaucSlot *slot, GError **error) {
	GError *ierror = NULL;
	gboolean res = FALSE;

	g_assert_nonnull(slot);
	g_assert_nonnull(slot->mount_point);
	g_assert_true(slot->mount_internal);

	res = r_umount(slot->mount_point, &ierror);
	if (!res) {
		res = FALSE;
		g_propagate_prefixed_error(
				error,
				ierror,
				"failed to unmount slot: ");
		goto out;
	}

	g_rmdir(slot->mount_point);
	g_clear_pointer(&slot->mount_point, g_free);
	slot->mount_internal = FALSE;

out:
	return res;
}
Beispiel #13
0
void migrateThemesToXdgDir(void)
{
	gchar *oldPath, *xdgPath;	

	xdgPath = g_build_filename(g_get_user_data_dir(), OBS_NAME, "themes", NULL);
	if (g_file_test(xdgPath, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
		g_free(xdgPath);
		return;
	}

	oldPath = g_build_filename(g_get_home_dir(), ".themes", OBS_NAME, NULL);
	if (!g_file_test(oldPath, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
		g_free(xdgPath);
		g_free(oldPath);
		return;
	}

	if( g_mkdir_with_parents(xdgPath, (S_IRUSR | S_IWUSR | S_IXUSR)) == -1) {
		printMessage(MSG_WARN,"Failed to create %s\n", xdgPath);
		g_free(xdgPath);
		g_free(oldPath);
		return;
	}

	if (!copyThemesDir("")) {
		printMessage(MSG_WARN,"Failed to migrate themes files\n");
		g_free(xdgPath);
		g_free(oldPath);
		return;
	}

	g_rmdir(oldPath);
	g_free(xdgPath);
	g_free(oldPath);
}
Beispiel #14
0
static void
fixture_tear_down(TestFixture *fixture, gconstpointer data)
{
    gchar *tmp;

    kill(fixture->pid, SIGTERM);

    g_main_loop_run(fixture->loop);
    g_main_loop_unref(fixture->loop);

    g_spawn_close_pid(fixture->pid);

    tmp = g_build_filename(fixture->test_dir, "foo", NULL);
    g_unlink(tmp);
    g_free(tmp);

    tmp = g_build_filename(fixture->test_dir, "qga.state", NULL);
    g_unlink(tmp);
    g_free(tmp);

    tmp = g_build_filename(fixture->test_dir, "sock", NULL);
    g_unlink(tmp);
    g_free(tmp);

    g_rmdir(fixture->test_dir);
    g_free(fixture->test_dir);
}
static gboolean
shell_xdg_migrate_rmdir (const gchar *dirname)
{
	GDir *dir = NULL;
	gboolean success = TRUE;

	if (g_file_test (dirname, G_FILE_TEST_IS_DIR)) {
		g_print ("  rmdir %s\n", dirname);
		if (g_rmdir (dirname) < 0) {
			g_printerr ("  FAILED: %s", g_strerror (errno));
			if (errno == ENOTEMPTY) {
				dir = g_dir_open (dirname, 0, NULL);
				g_printerr (" (contents follows)");
			}
			g_printerr ("\n");
			success = FALSE;
		}
	}

	/* List the directory's contents to aid debugging. */
	if (dir != NULL) {
		const gchar *basename;

		/* Align the filenames beneath the error message. */
		while ((basename = g_dir_read_name (dir)) != NULL)
			g_print ("          %s\n", basename);

		g_dir_close (dir);
	}

	return success;
}
void
e_migrate_base_dirs (EShell *shell)
{
	const gchar *home_dir;
	gchar *old_base_dir;

	g_return_if_fail (E_IS_SHELL (shell));

	/* XXX This blocks, but it's all just local file
	 *     renames so it should be nearly instantaneous. */

	home_dir = g_get_home_dir ();
	old_base_dir = g_build_filename (home_dir, ".evolution", NULL);

	/* Is there even anything to migrate? */
	if (!g_file_test (old_base_dir, G_FILE_TEST_IS_DIR))
		goto exit;

	shell_xdg_migrate_cache_dir (shell, old_base_dir);
	shell_xdg_migrate_config_dir (shell, old_base_dir);
	shell_xdg_migrate_data_dir (shell, old_base_dir);

	/* Try to remove the old base directory.  Good chance this will
	 * fail on the first try, since Evolution puts stuff here too. */
	g_rmdir (old_base_dir);

exit:
	g_free (old_base_dir);
}
Beispiel #17
0
static int
block_backend_fs_remove_store (BlockBackend *bend, const char *store_id)
{
    FsPriv *priv = bend->be_priv;
    char *block_dir = NULL;
    GDir *dir1, *dir2;
    const char *dname1, *dname2;
    char *path1, *path2;

    block_dir = g_build_filename (priv->block_dir, store_id, NULL);

    dir1 = g_dir_open (block_dir, 0, NULL);
    if (!dir1) {
        seaf_warning ("Failed to open block dir %s.\n", block_dir);
        g_free (block_dir);
        return -1;
    }

    while ((dname1 = g_dir_read_name(dir1)) != NULL) {
        path1 = g_build_filename (block_dir, dname1, NULL);

        dir2 = g_dir_open (path1, 0, NULL);
        if (!dir2) {
            seaf_warning ("Failed to open block dir %s.\n", path1);
            g_dir_close (dir1);
            g_free (path1);
            return -1;
        }

        while ((dname2 = g_dir_read_name(dir2)) != NULL) {
            path2 = g_build_filename (path1, dname2, NULL);
            g_unlink (path2);
            g_free (path2);
        }
        g_dir_close (dir2);

        g_rmdir (path1);
        g_free (path1);
    }

    g_dir_close (dir1);
    g_rmdir (block_dir);
    g_free (block_dir);

    return 0;
}
int has_efi_directory(PedPartition* part)
{
    int is_busy = ped_partition_is_busy(part);

    GError* error = NULL;

    char* mount_point = NULL;
    char *path = ped_partition_get_path(part);

    if (!is_busy) {
        mount_point = g_dir_make_tmp("efi_detectorXXXXXX", &error);
        if (error != NULL) {
            g_warning("[%s] create efi_detector failed :%s\n", __func__,
                      error->message);
            g_error_free(error);
            error = NULL;
        }
        char* cmd = g_strdup_printf ("mount -t vfat %s %s", path, mount_point);
        g_spawn_command_line_sync (cmd, NULL, NULL, NULL, &error);
        g_free(cmd);
        if (error != NULL) {
            g_warning("[%s] Can't detect whether is $ESP, cmd: %s, error: %s",
                      __func__, cmd, error->message);
            g_error_free(error);
            error = NULL;
            return FALSE;
        }
    }

    if (mount_point == NULL) {
        mount_point = get_partition_mount_point(path);
    }
    g_free(path);

    char* esp_path = g_build_filename(mount_point, "EFI", NULL);
    int is_esp = g_file_test (esp_path, G_FILE_TEST_IS_DIR);
    g_free(esp_path);

    if (!is_busy) {
        char* cmd = g_strdup_printf ("umount -l %s", mount_point);
        g_spawn_command_line_sync (cmd, NULL, NULL, NULL, &error);
        g_free(cmd);
        if (error != NULL) {
            g_warning("[%s] Can't detect whether is $ESP, cmd: %s, error: %s",
                      __func__, cmd, error->message);
            g_error_free(error);
            g_free(mount_point);
            return is_esp;
        }

        //don't rm the dir if umount failed.
        g_rmdir(mount_point);
        g_free(mount_point);
    }

    return is_esp;
}
Beispiel #19
0
void
_ev_file_helpers_shutdown (void)
{	
	if (tmp_dir != NULL)	
		g_rmdir (tmp_dir);

	g_free (tmp_dir);
	tmp_dir = NULL;
}
Beispiel #20
0
static int
unlink_entry (struct cache_entry *ce, struct unpack_trees_options *o)
{
    char path[SEAF_PATH_MAX];
    SeafStat st;
    int base_len = strlen(o->base);
    int len = ce_namelen(ce);
    int offset;

    if (!len) {
        g_warning ("entry name should not be empty.\n");
        return -1;
    }

    snprintf (path, SEAF_PATH_MAX, "%s/%s", o->base, ce->name);

    if (!S_ISDIR(ce->ce_mode)) {
        /* file doesn't exist in work tree */
        if (seaf_stat (path, &st) < 0 || !S_ISREG(st.st_mode)) {
            return 0;
        }

        /* file has been changed. */
        if (!o->reset &&
            (ce->ce_ctime.sec != st.st_ctime || ce->ce_mtime.sec != st.st_mtime)) {
            g_warning ("File %s is changed. Skip removing the file.\n", path);
            return -1;
        }

        /* first unlink the file. */
        if (g_unlink (path) < 0) {
            g_warning ("Failed to remove %s: %s.\n", path, strerror(errno));
            return -1;
        }
    } else {
        if (seaf_remove_empty_dir (path) < 0)
            return -1;
    }

    /* then remove all empty directories upwards. */
    offset = base_len + len;
    do {
        if (path[offset] == '/') {
            path[offset] = '\0';
            int ret = g_rmdir (path);
            if (ret < 0 && errno == ENOTEMPTY) {
                break;
            } else if (ret < 0) {
                g_warning ("Failed to remove %s: %s.\n", path, strerror(errno));
                return -1;
            }
        }
    } while (--offset > base_len);

    return 0;
}
static void webkitFaviconDatabaseFinalizedCallback(gpointer, GObject*)
{
    if (!g_file_test(kTempDirectory, G_FILE_TEST_IS_DIR))
        return;

    GUniquePtr<char> filename(g_build_filename(kTempDirectory, "WebpageIcons.db", nullptr));
    g_unlink(filename.get());

    g_rmdir(kTempDirectory);
}
Beispiel #22
0
bool M_DeleteFolder(const char *path) {
  int res = g_rmdir(path);

  if (res == -1) {
    set_file_error_from_errno();
    return false;
  }

  return true;
}
Beispiel #23
0
static void removeNonEmptyDirectory(const char* directoryPath)
{
    GDir* directory = g_dir_open(directoryPath, 0, 0);
    g_assert(directory);
    const char* fileName;
    while ((fileName = g_dir_read_name(directory))) {
        GOwnPtr<char> filePath(g_build_filename(directoryPath, fileName, NULL));
        g_unlink(filePath.get());
    }
    g_dir_close(directory);
    g_rmdir(directoryPath);
}
Beispiel #24
0
void PurpleLine::close() {
    disconnect_signals();

    if (temp_files.size()) {
        for (std::string &path: temp_files)
            g_unlink(path.c_str());

        g_rmdir(get_tmp_dir().c_str());
    }

    delete this;
}
Beispiel #25
0
int
seaf_remove_empty_dir (const char *path)
{
    SeafStat st;
    GDir *dir;
    const char *dname;
    char *full_path;
    GError *error = NULL;

    if (seaf_stat (path, &st) < 0 || !S_ISDIR(st.st_mode))
        return 0;

    if (g_rmdir (path) < 0) {
        dir = g_dir_open (path, 0, &error);
        if (!dir) {
            seaf_warning ("Failed to open dir %s: %s.\n", path, error->message);
            return -1;
        }

        /* Remove all ignored hidden files. */
        while ((dname = g_dir_read_name (dir)) != NULL) {
            if (seaf_repo_manager_is_ignored_hidden_file(dname)) {
                full_path = g_build_path ("/", path, dname, NULL);
                if (g_unlink (full_path) < 0)
                    seaf_warning ("Failed to remove file %s: %s.\n",
                                  full_path, strerror(errno));
                g_free (full_path);
            }
        }

        g_dir_close (dir);

        if (g_rmdir (path) < 0) {
            seaf_warning ("Failed to remove dir %s: %s.\n", path, strerror(errno));
            return -1;
        }
    }

    return 0;
}
Beispiel #26
0
/**
 * as_utils_delete_dir_recursive:
 * @dirname: Directory to remove
 *
 * Remove directory and all its children (like rm -r does).
 *
 * Returns: %TRUE if operation was successful
 */
gboolean
as_utils_delete_dir_recursive (const gchar* dirname)
{
	GError *error = NULL;
	gboolean ret = FALSE;
	GFile *dir;
	GFileEnumerator *enr;
	GFileInfo *info;
	g_return_val_if_fail (dirname != NULL, FALSE);

	if (!g_file_test (dirname, G_FILE_TEST_IS_DIR))
		return TRUE;

	dir = g_file_new_for_path (dirname);
	enr = g_file_enumerate_children (dir, "standard::name", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, &error);
	if (error != NULL)
		goto out;

	if (enr == NULL)
		goto out;
	info = g_file_enumerator_next_file (enr, NULL, &error);
	if (error != NULL)
		goto out;
	while (info != NULL) {
		gchar *path;
		path = g_build_filename (dirname, g_file_info_get_name (info), NULL);
		if (g_file_test (path, G_FILE_TEST_IS_DIR)) {
			as_utils_delete_dir_recursive (path);
		} else {
			g_remove (path);
		}
		g_object_unref (info);
		info = g_file_enumerator_next_file (enr, NULL, &error);
		if (error != NULL)
			goto out;
	}
	if (g_file_test (dirname, G_FILE_TEST_EXISTS)) {
		g_rmdir (dirname);
	}
	ret = TRUE;

out:
	g_object_unref (dir);
	if (enr != NULL)
		g_object_unref (enr);
	if (error != NULL) {
		g_critical ("Could not remove directory: %s", error->message);
		g_error_free (error);
	}
	return ret;
}
Beispiel #27
0
static void
unix_path_destroy (gchar *unix_path)
{
  if (unix_path != NULL)
    {
      gchar *p;

      g_unlink (unix_path);
      p = g_strrstr (unix_path, G_DIR_SEPARATOR_S);
      *p = '\0';
      g_rmdir (unix_path);
      g_free (unix_path);
    }
}
Beispiel #28
0
static void deleteDatabaseFileIfExists(const char *databasePath)
{
    if (!g_file_test(databasePath, G_FILE_TEST_IS_DIR))
        return;

    char *databaseFilename = g_build_filename(databasePath, "WebpageIcons.db", NULL);
    if (g_unlink(databaseFilename) == -1) {
        g_free(databaseFilename);
        return;
    }

    g_free(databaseFilename);
    g_rmdir(databasePath);
}
Beispiel #29
0
int  ug_delete_dir (const gchar *dir_utf8)
{
	if (g_get_filename_charsets (NULL))
		return g_rmdir (dir_utf8);
	else {
		gchar *cp_filename = g_filename_from_utf8 (dir_utf8, -1, NULL, NULL, NULL);
		int save_errno;
		int retval;

		if (cp_filename == NULL) {
			errno = EINVAL;
			return -1;
		}

		retval = g_rmdir (cp_filename);
		save_errno = errno;

		g_free (cp_filename);

		errno = save_errno;
		return retval;
	}
}
Beispiel #30
0
static void cleanup_old_file(const char *path)
{
    char *p = fs_uae_expand_path(path);
    if (fs_path_exists(p)) {
        if (fs_path_is_dir(p)) {
            fs_log("trying to remove old directory %s\n", p);
            g_rmdir(p);
        }
        else {
            fs_log("trying to remove old file %s\n", p);
            g_unlink(p);
        }
    }
    free(p);
}