1999-01-07 04:14:50 +03:00
|
|
|
/* File operation contexts for the Midnight Commander
|
2002-08-27 09:27:11 +04:00
|
|
|
|
2007-09-25 19:33:35 +04:00
|
|
|
Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2007
|
|
|
|
Free Software Foundation, Inc.
|
2002-08-27 09:27:11 +04:00
|
|
|
|
|
|
|
Authors: Federico Mena <federico@nuclecu.unam.mx>
|
|
|
|
Miguel de Icaza <miguel@nuclecu.unam.mx>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2005-05-27 07:35:10 +04:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
1999-01-07 04:14:50 +03:00
|
|
|
*/
|
|
|
|
|
2009-02-05 21:28:18 +03:00
|
|
|
/** \file fileopctx.c
|
|
|
|
* \brief Source: file operation contexts
|
|
|
|
* \date 1998-2007
|
|
|
|
* \author Federico Mena <federico@nuclecu.unam.mx>
|
|
|
|
* \author Miguel de Icaza <miguel@nuclecu.unam.mx>
|
|
|
|
*/
|
|
|
|
|
1999-01-07 04:14:50 +03:00
|
|
|
#include <config.h>
|
2005-02-08 12:04:03 +03:00
|
|
|
|
1999-01-07 04:14:50 +03:00
|
|
|
#include <unistd.h>
|
2001-09-07 21:52:19 +04:00
|
|
|
|
|
|
|
#include "global.h"
|
1999-01-07 04:14:50 +03:00
|
|
|
#include "fileopctx.h"
|
2009-05-06 20:12:32 +04:00
|
|
|
#include "../src/search/search.h"
|
1999-01-07 04:14:50 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-02-07 00:09:50 +03:00
|
|
|
* \fn FileOpContext * file_op_context_new (FileOperation op)
|
|
|
|
* \param op file operation struct
|
|
|
|
* \return The newly-created context, filled with the default file mask values.
|
2009-02-05 21:28:18 +03:00
|
|
|
*
|
1999-01-07 04:14:50 +03:00
|
|
|
* Creates a new file operation context with the default values. If you later want
|
2009-02-07 00:09:50 +03:00
|
|
|
* to have a user interface for this, call file_op_context_create_ui().
|
2009-02-05 21:28:18 +03:00
|
|
|
*/
|
1999-01-07 04:14:50 +03:00
|
|
|
FileOpContext *
|
2004-01-24 00:59:38 +03:00
|
|
|
file_op_context_new (FileOperation op)
|
1999-01-07 04:14:50 +03:00
|
|
|
{
|
2002-10-25 00:25:07 +04:00
|
|
|
FileOpContext *ctx;
|
|
|
|
|
|
|
|
ctx = g_new0 (FileOpContext, 1);
|
2004-01-24 00:59:38 +03:00
|
|
|
ctx->operation = op;
|
2002-10-25 00:25:07 +04:00
|
|
|
ctx->eta_secs = 0.0;
|
|
|
|
ctx->progress_bytes = 0.0;
|
|
|
|
ctx->op_preserve = TRUE;
|
|
|
|
ctx->do_reget = TRUE;
|
2005-05-23 15:30:07 +04:00
|
|
|
ctx->stat_func = mc_lstat;
|
2002-10-25 00:25:07 +04:00
|
|
|
ctx->preserve = TRUE;
|
|
|
|
ctx->preserve_uidgid = (geteuid () == 0) ? TRUE : FALSE;
|
|
|
|
ctx->umask_kill = 0777777;
|
|
|
|
ctx->erase_at_end = TRUE;
|
|
|
|
|
|
|
|
return ctx;
|
1999-01-07 04:14:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-02-07 00:09:50 +03:00
|
|
|
* \fn void file_op_context_destroy (FileOpContext *ctx)
|
|
|
|
* \param ctx The file operation context to destroy.
|
2009-02-05 21:28:18 +03:00
|
|
|
*
|
1999-01-07 04:14:50 +03:00
|
|
|
* Destroys the specified file operation context and its associated UI data, if
|
|
|
|
* it exists.
|
2009-02-05 21:28:18 +03:00
|
|
|
*/
|
1999-01-07 04:14:50 +03:00
|
|
|
void
|
|
|
|
file_op_context_destroy (FileOpContext *ctx)
|
|
|
|
{
|
2002-10-25 00:25:07 +04:00
|
|
|
g_return_if_fail (ctx != NULL);
|
1999-01-07 04:14:50 +03:00
|
|
|
|
2002-10-25 00:25:07 +04:00
|
|
|
if (ctx->ui)
|
|
|
|
file_op_context_destroy_ui (ctx);
|
1999-01-07 04:14:50 +03:00
|
|
|
|
2009-05-06 20:12:32 +04:00
|
|
|
mc_search_free(ctx->search_handle);
|
2002-12-26 22:04:10 +03:00
|
|
|
|
2009-02-07 00:09:50 +03:00
|
|
|
/** \todo FIXME: do we need to free ctx->dest_mask? */
|
1999-01-07 04:14:50 +03:00
|
|
|
|
2009-02-06 01:27:37 +03:00
|
|
|
g_free (ctx);
|
1999-01-07 04:14:50 +03:00
|
|
|
}
|