mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 12:56:51 +03:00
Ticket #1609: Do not modify file name in file operations.
Initial step: minor refactoring. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
551ca67e8f
commit
0cd390fd50
21
src/file.c
21
src/file.c
@ -150,26 +150,29 @@ static FileProgressStatus transform_error = FILE_CONT;
|
|||||||
static char *
|
static char *
|
||||||
transform_source (FileOpContext *ctx, const char *source)
|
transform_source (FileOpContext *ctx, const char *source)
|
||||||
{
|
{
|
||||||
char *s = g_strdup (source);
|
char *s, *q;
|
||||||
char *q;
|
char *fnsource;
|
||||||
char *fnsource = (char*)x_basename (s);
|
|
||||||
|
s = g_strdup (source);
|
||||||
|
|
||||||
/* We remove \n from the filename since regex routines would use \n as an anchor */
|
/* We remove \n from the filename since regex routines would use \n as an anchor */
|
||||||
/* this is just to be allowed to maniupulate file names with \n on it */
|
/* this is just to be allowed to maniupulate file names with \n on it */
|
||||||
for (q = s; *q; q++) {
|
for (q = s; *q != '\0'; q++)
|
||||||
if (*q == '\n')
|
if (*q == '\n')
|
||||||
*q = ' ';
|
*q = ' ';
|
||||||
}
|
|
||||||
|
|
||||||
|
fnsource = (char *) x_basename (s);
|
||||||
str_fix_string (fnsource);
|
str_fix_string (fnsource);
|
||||||
|
|
||||||
if ( ! mc_search_run(ctx->search_handle, fnsource, 0, strlen (fnsource), NULL) ){
|
if (mc_search_run (ctx->search_handle, fnsource, 0, strlen (fnsource), NULL))
|
||||||
|
q = mc_search_prepare_replace_str2 (ctx->search_handle, ctx->dest_mask);
|
||||||
|
else {
|
||||||
|
q = NULL;
|
||||||
transform_error = FILE_SKIP;
|
transform_error = FILE_SKIP;
|
||||||
g_free (s);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (s);
|
g_free (s);
|
||||||
return mc_search_prepare_replace_str2 (ctx->search_handle, ctx->dest_mask);
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user