Example #1
0
File: tree.c Project: ebichu/dd-wrt
static void
tree_rmdir_cmd (WTree *tree)
{
    off_t count = 0;
    double bytes = 0;
    FileOpContext *ctx;

    if (!tree->selected_ptr)
	return;

    if (confirm_delete) {
	char *buf;
	int result;

	buf =
	    g_strdup_printf (_("  Delete %s?  "),
			     tree->selected_ptr->name);
	result =
	    query_dialog (_(" Delete "), buf, 3, 2, _("&Yes"), _("&No"));
	g_free (buf);
	if (result != 0)
	    return;
    }

    ctx = file_op_context_new (OP_DELETE);
    file_op_context_create_ui (ctx, FALSE);
    if (erase_dir (ctx, tree->selected_ptr->name, &count, &bytes) ==
	FILE_CONT)
	tree_forget_cmd (tree);
    file_op_context_destroy (ctx);
}
Example #2
0
static void
tree_rmdir (void *data)
{
    WTree *tree = data;
    file_op_context_t *ctx;
    file_op_total_context_t *tctx;

    if (!tree->selected_ptr)
        return;

    if (confirm_delete)
    {
        char *buf;
        int result;

        buf = g_strdup_printf (_("Delete %s?"), vfs_path_as_str (tree->selected_ptr->name));

        result = query_dialog (Q_ ("DialogTitle|Delete"), buf, D_ERROR, 2, _("&Yes"), _("&No"));
        g_free (buf);
        if (result != 0)
            return;
    }

    ctx = file_op_context_new (OP_DELETE);
    tctx = file_op_total_context_new ();

    file_op_context_create_ui (ctx, FALSE, FILEGUI_DIALOG_ONE_ITEM);
    if (erase_dir (tctx, ctx, tree->selected_ptr->name) == FILE_CONT)
        tree_forget (tree);
    file_op_total_context_destroy (tctx);
    file_op_context_destroy (ctx);
}
Example #3
0
static void
tree_copy (WTree * tree, const char *default_dest)
{
    char msg[BUF_MEDIUM];
    char *dest;

    if (tree->selected_ptr == NULL)
        return;

    g_snprintf (msg, sizeof (msg), _("Copy \"%s\" directory to:"),
                str_trunc (vfs_path_as_str (tree->selected_ptr->name), 50));
    dest = input_expand_dialog (Q_ ("DialogTitle|Copy"),
                                msg, MC_HISTORY_FM_TREE_COPY, default_dest,
                                INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_CD);

    if (dest != NULL && *dest != '\0')
    {
        file_op_context_t *ctx;
        file_op_total_context_t *tctx;

        ctx = file_op_context_new (OP_COPY);
        tctx = file_op_total_context_new ();
        file_op_context_create_ui (ctx, FALSE, FILEGUI_DIALOG_MULTI_ITEM);
        tctx->ask_overwrite = FALSE;
        copy_dir_dir (tctx, ctx, vfs_path_as_str (tree->selected_ptr->name), dest, TRUE, FALSE,
                      FALSE, NULL);
        file_op_total_context_destroy (tctx);
        file_op_context_destroy (ctx);
    }

    g_free (dest);
}
Example #4
0
File: tree.c Project: ebichu/dd-wrt
static void tree_copy (WTree *tree, const char *default_dest)
{
    char   *dest;
    off_t  count = 0;
    double bytes = 0;
    FileOpContext *ctx;

    if (!tree->selected_ptr)
	return;
    g_snprintf (cmd_buf, sizeof(cmd_buf), _("Copy \"%s\" directory to:"),
	     name_trunc (tree->selected_ptr->name, 50));
    dest = input_expand_dialog (_(" Copy "), cmd_buf, MC_HISTORY_FM_TREE_COPY, default_dest);

    if (!dest)
	return;

    if (!*dest){
	g_free (dest);
	return;
    }

    ctx = file_op_context_new (OP_COPY);
    file_op_context_create_ui (ctx, FALSE);
    copy_dir_dir (ctx, tree->selected_ptr->name, dest, 1, 0, 0, 0, &count, &bytes);
    file_op_context_destroy (ctx);

    g_free (dest);
}
Example #5
0
static void
tree_copy (WTree *tree, const char *default_dest)
{
    char   msg [BUF_MEDIUM];
    char   *dest;
    off_t  count = 0;
    double bytes = 0;
    FileOpContext *ctx;

    if (tree->selected_ptr == NULL)
	return;

    g_snprintf (msg, sizeof (msg), _("Copy \"%s\" directory to:"),
			str_trunc (tree->selected_ptr->name, 50));
    dest = input_expand_dialog (_(" Copy "), msg, MC_HISTORY_FM_TREE_COPY, default_dest);

    if (dest != NULL && *dest != '\0') {
	ctx = file_op_context_new (OP_COPY);
	file_op_context_create_ui (ctx, FALSE);
	copy_dir_dir (ctx, tree->selected_ptr->name, dest, 1, 0, 0, 0, &count, &bytes);
	file_op_context_destroy (ctx);
    }

    g_free (dest);
}
Example #6
0
static void
tree_move (WTree * tree, const char *default_dest)
{
    char msg[BUF_MEDIUM];
    char *dest;
    struct stat buf;
    file_op_context_t *ctx;
    file_op_total_context_t *tctx;
    vfs_path_t *dest_vpath = NULL;

    if (tree->selected_ptr == NULL)
        return;

    g_snprintf (msg, sizeof (msg), _("Move \"%s\" directory to:"),
                str_trunc (vfs_path_as_str (tree->selected_ptr->name), 50));
    dest =
        input_expand_dialog (Q_ ("DialogTitle|Move"), msg, MC_HISTORY_FM_TREE_MOVE, default_dest,
                             INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_CD);

    if (dest == NULL || *dest == '\0')
        goto ret;

    dest_vpath = vfs_path_from_str (dest);

    if (mc_stat (dest_vpath, &buf))
    {
        message (D_ERROR, MSG_ERROR, _("Cannot stat the destination\n%s"),
                 unix_error_string (errno));
        goto ret;
    }

    if (!S_ISDIR (buf.st_mode))
    {
        file_error (_("Destination \"%s\" must be a directory\n%s"), dest);
        goto ret;
    }

    ctx = file_op_context_new (OP_MOVE);
    tctx = file_op_total_context_new ();
    file_op_context_create_ui (ctx, FALSE, FILEGUI_DIALOG_ONE_ITEM);
    move_dir_dir (tctx, ctx, vfs_path_as_str (tree->selected_ptr->name), dest);
    file_op_total_context_destroy (tctx);
    file_op_context_destroy (ctx);

  ret:
    vfs_path_free (dest_vpath);
    g_free (dest);
}
Example #7
0
/* If not copy the default */
static int
check_for_default(char *default_file, char *file)
{
    struct stat s;
    off_t  count = 0;
    double bytes = 0;
    FileOpContext *ctx;
    
    if (mc_stat (file, &s)){
	if (mc_stat (default_file, &s)){
	    return -1;
	}
	ctx = file_op_context_new (OP_COPY);
	file_op_context_create_ui (ctx, 0);
	copy_file_file (ctx, default_file, file, 1, &count, &bytes, 1);
	file_op_context_destroy (ctx);
    }
    return 0;
}
Example #8
0
static void
tree_move (WTree *tree, const char *default_dest)
{
    char   msg [BUF_MEDIUM];
    char   *dest;
    struct stat buf;
    double bytes = 0;
    off_t  count = 0;
    FileOpContext *ctx;

    if (tree->selected_ptr == NULL)
	return;

    g_snprintf (msg, sizeof (msg), _("Move \"%s\" directory to:"),
			str_trunc (tree->selected_ptr->name, 50));
    dest = input_expand_dialog (_(" Move "), msg, MC_HISTORY_FM_TREE_MOVE, default_dest);

    if (dest == NULL || *dest == '\0') {
	g_free (dest);
	return;
    }

    if (stat (dest, &buf)){
	message (D_ERROR, MSG_ERROR, _(" Cannot stat the destination \n %s "),
		 unix_error_string (errno));
	g_free (dest);
	return;
    }
    if (!S_ISDIR (buf.st_mode)){
	file_error (_(" Destination \"%s\" must be a directory \n %s "),
		    dest);
	g_free (dest);
	return;
    }

    ctx = file_op_context_new (OP_MOVE);
    file_op_context_create_ui (ctx, FALSE);
    move_dir_dir (ctx, tree->selected_ptr->name, dest, &count, &bytes);
    file_op_context_destroy (ctx);

    g_free (dest);
}
Example #9
0
int
check_for_default (const char *default_file, const char *file)
{
    if (!exist_file (file))
    {
        FileOpContext *ctx;
        FileOpTotalContext *tctx;

        if (!exist_file (default_file))
            return -1;

        ctx = file_op_context_new (OP_COPY);
        tctx = file_op_total_context_new ();
        file_op_context_create_ui (ctx, 0, FALSE);
        copy_file_file (tctx, ctx, default_file, file);
        file_op_total_context_destroy (tctx);
        file_op_context_destroy (ctx);
    }

    return 0;
}
Example #10
0
gboolean
check_for_default (const vfs_path_t * default_file_vpath, const vfs_path_t * file_vpath)
{
    if (!exist_file (vfs_path_as_str (file_vpath)))
    {
        file_op_context_t *ctx;
        file_op_total_context_t *tctx;

        if (!exist_file (vfs_path_as_str (default_file_vpath)))
            return FALSE;

        ctx = file_op_context_new (OP_COPY);
        tctx = file_op_total_context_new ();
        file_op_context_create_ui (ctx, 0, FALSE);
        copy_file_file (tctx, ctx, vfs_path_as_str (default_file_vpath),
                        vfs_path_as_str (file_vpath));
        file_op_total_context_destroy (tctx);
        file_op_context_destroy (ctx);
    }

    return TRUE;
}