Remove vfs_path_to_str() function for avoid often memory allocations.
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Этот коммит содержится в:
родитель
31bacf56c9
Коммит
2640b21bb9
19
lib/util.c
19
lib/util.c
@ -2,7 +2,7 @@
|
||||
Various utilities
|
||||
|
||||
Copyright (C) 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003,
|
||||
2004, 2005, 2007, 2009, 2011
|
||||
2004, 2005, 2007, 2009, 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
@ -11,6 +11,7 @@
|
||||
Dugan Porter, 1994, 1995, 1996
|
||||
Jakub Jelinek, 1994, 1995, 1996
|
||||
Mauricio Plaza, 1994, 1995, 1996
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -116,7 +117,7 @@ resolve_symlinks (const vfs_path_t * vpath)
|
||||
if (vpath->relative)
|
||||
return NULL;
|
||||
|
||||
p = p2 = vfs_path_to_str (vpath);
|
||||
p = p2 = g_strdup (vfs_path_as_str (vpath));
|
||||
r = buf = g_malloc (MC_MAXPATHLEN);
|
||||
buf2 = g_malloc (MC_MAXPATHLEN);
|
||||
*r++ = PATH_SEP;
|
||||
@ -1098,7 +1099,6 @@ load_file_position (const vfs_path_t * filename_vpath, long *line, long *column,
|
||||
FILE *f;
|
||||
char buf[MC_MAXPATHLEN + 100];
|
||||
const size_t len = vfs_path_len (filename_vpath);
|
||||
char *filename;
|
||||
|
||||
/* defaults */
|
||||
*line = 1;
|
||||
@ -1115,7 +1115,6 @@ load_file_position (const vfs_path_t * filename_vpath, long *line, long *column,
|
||||
/* prepare array for serialized bookmarks */
|
||||
if (bookmarks != NULL)
|
||||
*bookmarks = g_array_sized_new (FALSE, FALSE, sizeof (size_t), MAX_SAVED_BOOKMARKS);
|
||||
filename = vfs_path_to_str (filename_vpath);
|
||||
|
||||
while (fgets (buf, sizeof (buf), f) != NULL)
|
||||
{
|
||||
@ -1123,7 +1122,7 @@ load_file_position (const vfs_path_t * filename_vpath, long *line, long *column,
|
||||
gchar **pos_tokens;
|
||||
|
||||
/* check if the filename matches the beginning of string */
|
||||
if (strncmp (buf, filename, len) != 0)
|
||||
if (strncmp (buf, vfs_path_as_str (filename_vpath), len) != 0)
|
||||
continue;
|
||||
|
||||
/* followed by single space */
|
||||
@ -1175,7 +1174,6 @@ load_file_position (const vfs_path_t * filename_vpath, long *line, long *column,
|
||||
g_strfreev (pos_tokens);
|
||||
}
|
||||
|
||||
g_free (filename);
|
||||
fclose (f);
|
||||
}
|
||||
|
||||
@ -1195,7 +1193,6 @@ save_file_position (const vfs_path_t * filename_vpath, long line, long column, o
|
||||
size_t i;
|
||||
const size_t len = vfs_path_len (filename_vpath);
|
||||
gboolean src_error = FALSE;
|
||||
char *filename;
|
||||
|
||||
if (filepos_max_saved_entries == 0)
|
||||
filepos_max_saved_entries = mc_config_get_int (mc_main_config, CONFIG_APP_SECTION,
|
||||
@ -1220,11 +1217,12 @@ save_file_position (const vfs_path_t * filename_vpath, long line, long column, o
|
||||
goto open_source_error;
|
||||
}
|
||||
|
||||
filename = vfs_path_to_str (filename_vpath);
|
||||
/* put the new record */
|
||||
if (line != 1 || column != 0 || bookmarks != NULL)
|
||||
{
|
||||
if (fprintf (f, "%s %ld;%ld;%" PRIuMAX, filename, line, column, (uintmax_t) offset) < 0)
|
||||
if (fprintf
|
||||
(f, "%s %ld;%ld;%" PRIuMAX, vfs_path_as_str (filename_vpath), line, column,
|
||||
(uintmax_t) offset) < 0)
|
||||
goto write_position_error;
|
||||
if (bookmarks != NULL)
|
||||
for (i = 0; i < bookmarks->len && i < MAX_SAVED_BOOKMARKS; i++)
|
||||
@ -1238,7 +1236,7 @@ save_file_position (const vfs_path_t * filename_vpath, long line, long column, o
|
||||
i = 1;
|
||||
while (fgets (buf, sizeof (buf), tmp_f) != NULL)
|
||||
{
|
||||
if (buf[len] == ' ' && strncmp (buf, filename, len) == 0
|
||||
if (buf[len] == ' ' && strncmp (buf, vfs_path_as_str (filename_vpath), len) == 0
|
||||
&& strchr (&buf[len + 1], ' ') == NULL)
|
||||
continue;
|
||||
|
||||
@ -1248,7 +1246,6 @@ save_file_position (const vfs_path_t * filename_vpath, long line, long column, o
|
||||
}
|
||||
|
||||
write_position_error:
|
||||
g_free (filename);
|
||||
fclose (tmp_f);
|
||||
open_source_error:
|
||||
g_free (tmp_fn);
|
||||
|
@ -1,11 +1,12 @@
|
||||
/*
|
||||
Directory cache support
|
||||
|
||||
Copyright (C) 1998, 2011
|
||||
Copyright (C) 1998, 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Pavel Machek <pavel@ucw.cz>, 1998
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -1260,7 +1261,7 @@ vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode)
|
||||
vfs_path_t *tmp_vpath;
|
||||
|
||||
tmp_handle = vfs_mkstemps (&tmp_vpath, path_element->class->name, name);
|
||||
ino->localname = vfs_path_to_str (tmp_vpath);
|
||||
ino->localname = g_strdup (vfs_path_as_str (tmp_vpath));
|
||||
vfs_path_free (tmp_vpath);
|
||||
if (tmp_handle == -1)
|
||||
{
|
||||
@ -1353,7 +1354,7 @@ vfs_s_retrieve_file (struct vfs_class *me, struct vfs_s_inode *ino)
|
||||
fh.handle = -1;
|
||||
|
||||
handle = vfs_mkstemps (&tmp_vpath, me->name, ino->ent->name);
|
||||
ino->localname = vfs_path_to_str (tmp_vpath);
|
||||
ino->localname = g_strdup (vfs_path_as_str (tmp_vpath));
|
||||
vfs_path_free (tmp_vpath);
|
||||
if (handle == -1)
|
||||
{
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
Virtual File System: interface functions
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -878,16 +878,12 @@ mc_tmpdir (void)
|
||||
g_free (fallback_prefix);
|
||||
if (test_fd != -1)
|
||||
{
|
||||
char *test_fn;
|
||||
|
||||
test_fn = vfs_path_to_str (test_vpath);
|
||||
close (test_fd);
|
||||
test_fd = open (test_fn, O_RDONLY);
|
||||
g_free (test_fn);
|
||||
test_fd = open (vfs_path_as_str (test_vpath), O_RDONLY);
|
||||
if (test_fd != -1)
|
||||
{
|
||||
close (test_fd);
|
||||
unlink (test_fn);
|
||||
unlink (vfs_path_as_str (test_vpath));
|
||||
fallback_ok = TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
Virtual File System path handlers
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -591,8 +591,6 @@ vfs_path_strip_home (const char *dir)
|
||||
return g_strdup (dir);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -713,21 +711,6 @@ vfs_path_to_str_elements_count (const vfs_path_t * vpath, int elements_count)
|
||||
return vfs_path_to_str_flags (vpath, elements_count, VPF_NONE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Convert vfs_path_t to string representation.
|
||||
*
|
||||
* @param vpath pointer to vfs_path_t object
|
||||
*
|
||||
* @return pointer to newly created string.
|
||||
*/
|
||||
|
||||
char *
|
||||
vfs_path_to_str (const vfs_path_t * vpath)
|
||||
{
|
||||
return vfs_path_to_str_elements_count (vpath, vfs_path_elements_count (vpath));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Split path string to path elements with flags for change parce process.
|
||||
@ -760,6 +743,7 @@ vfs_path_from_str_flags (const char *path_str, vfs_path_flag_t flags)
|
||||
else
|
||||
vpath = vfs_path_from_str_uri_parser (path, flags);
|
||||
|
||||
vpath->str = vfs_path_to_str_flags (vpath, 0, VPF_NONE);
|
||||
g_free (path);
|
||||
|
||||
return vpath;
|
||||
@ -824,6 +808,8 @@ void
|
||||
vfs_path_add_element (const vfs_path_t * vpath, const vfs_path_element_t * path_element)
|
||||
{
|
||||
g_array_append_val (vpath->path, path_element);
|
||||
g_free (vpath->str);
|
||||
((vfs_path_t *) vpath)->str = vfs_path_to_str_flags (vpath, 0, VPF_NONE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -944,6 +930,7 @@ vfs_path_clone (const vfs_path_t * vpath)
|
||||
path_element = vfs_path_element_clone (vfs_path_get_by_index (vpath, vpath_element_index));
|
||||
g_array_append_val (new_vpath->path, path_element);
|
||||
}
|
||||
new_vpath->str = g_strdup (vpath->str);
|
||||
|
||||
return new_vpath;
|
||||
}
|
||||
@ -974,6 +961,7 @@ vfs_path_free (vfs_path_t * vpath)
|
||||
}
|
||||
|
||||
g_array_free (vpath->path, TRUE);
|
||||
g_free (vpath->str);
|
||||
g_free (vpath);
|
||||
}
|
||||
|
||||
@ -1000,6 +988,8 @@ vfs_path_remove_element_by_index (vfs_path_t * vpath, int element_index)
|
||||
element = (vfs_path_element_t *) vfs_path_get_by_index (vpath, element_index);
|
||||
vpath->path = g_array_remove_index (vpath->path, element_index);
|
||||
vfs_path_element_free (element);
|
||||
g_free (vpath->str);
|
||||
vpath->str = vfs_path_to_str_flags (vpath, 0, VPF_NONE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1185,6 +1175,7 @@ vfs_path_deserialize (const char *data, GError ** error)
|
||||
g_set_error (error, MC_ERROR, -1, "No any path elements found");
|
||||
return NULL;
|
||||
}
|
||||
vpath->str = vfs_path_to_str_flags (vpath, 0, VPF_NONE);
|
||||
|
||||
return vpath;
|
||||
}
|
||||
@ -1232,7 +1223,8 @@ vfs_path_t *
|
||||
vfs_path_append_new (const vfs_path_t * vpath, const char *first_element, ...)
|
||||
{
|
||||
va_list args;
|
||||
char *str_path, *result_str;
|
||||
char *str_path;
|
||||
const char *result_str;
|
||||
vfs_path_t *ret_vpath;
|
||||
|
||||
if (vpath == NULL || first_element == NULL)
|
||||
@ -1242,9 +1234,8 @@ vfs_path_append_new (const vfs_path_t * vpath, const char *first_element, ...)
|
||||
str_path = mc_build_filenamev (first_element, args);
|
||||
va_end (args);
|
||||
|
||||
result_str = vfs_path_to_str (vpath);
|
||||
result_str = vfs_path_as_str (vpath);
|
||||
ret_vpath = vfs_path_build_filename (result_str, str_path, NULL);
|
||||
g_free (result_str);
|
||||
g_free (str_path);
|
||||
|
||||
return ret_vpath;
|
||||
@ -1291,6 +1282,8 @@ vfs_path_append_vpath_new (const vfs_path_t * first_vpath, ...)
|
||||
while (current_vpath != NULL);
|
||||
va_end (args);
|
||||
|
||||
ret_vpath->str = vfs_path_to_str_flags (ret_vpath, 0, VPF_NONE);
|
||||
|
||||
return ret_vpath;
|
||||
}
|
||||
|
||||
@ -1535,21 +1528,17 @@ vfs_path_element_build_pretty_path_str (const vfs_path_element_t * element)
|
||||
gboolean
|
||||
vfs_path_equal (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
|
||||
{
|
||||
char *path1;
|
||||
char *path2;
|
||||
const char *path1, *path2;
|
||||
gboolean ret_val;
|
||||
|
||||
if (vpath1 == NULL || vpath2 == NULL)
|
||||
return FALSE;
|
||||
|
||||
path1 = vfs_path_to_str (vpath1);
|
||||
path2 = vfs_path_to_str (vpath2);
|
||||
path1 = vfs_path_as_str (vpath1);
|
||||
path2 = vfs_path_as_str (vpath2);
|
||||
|
||||
ret_val = strcmp (path1, path2) == 0;
|
||||
|
||||
g_free (path1);
|
||||
g_free (path2);
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
@ -1567,21 +1556,17 @@ vfs_path_equal (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
|
||||
gboolean
|
||||
vfs_path_equal_len (const vfs_path_t * vpath1, const vfs_path_t * vpath2, size_t len)
|
||||
{
|
||||
char *path1;
|
||||
char *path2;
|
||||
const char *path1, *path2;
|
||||
gboolean ret_val;
|
||||
|
||||
if (vpath1 == NULL || vpath2 == NULL)
|
||||
return FALSE;
|
||||
|
||||
path1 = vfs_path_to_str (vpath1);
|
||||
path2 = vfs_path_to_str (vpath2);
|
||||
path1 = vfs_path_as_str (vpath1);
|
||||
path2 = vfs_path_as_str (vpath2);
|
||||
|
||||
ret_val = strncmp (path1, path2, len) == 0;
|
||||
|
||||
g_free (path1);
|
||||
g_free (path2);
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
@ -1597,16 +1582,10 @@ vfs_path_equal_len (const vfs_path_t * vpath1, const vfs_path_t * vpath2, size_t
|
||||
size_t
|
||||
vfs_path_len (const vfs_path_t * vpath)
|
||||
{
|
||||
char *path;
|
||||
size_t ret_val;
|
||||
|
||||
if (vpath == NULL)
|
||||
return 0;
|
||||
|
||||
path = vfs_path_to_str (vpath);
|
||||
ret_val = strlen (path);
|
||||
g_free (path);
|
||||
return ret_val;
|
||||
return strlen (vpath->str);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1622,14 +1601,13 @@ vfs_path_t *
|
||||
vfs_path_to_absolute (const vfs_path_t * vpath)
|
||||
{
|
||||
vfs_path_t *absolute_vpath;
|
||||
char *path_str;
|
||||
const char *path_str;
|
||||
|
||||
if (!vpath->relative)
|
||||
return vfs_path_clone (vpath);
|
||||
|
||||
path_str = vfs_path_to_str (vpath);
|
||||
path_str = vfs_path_as_str (vpath);
|
||||
absolute_vpath = vfs_path_from_str (path_str);
|
||||
g_free (path_str);
|
||||
return absolute_vpath;
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ typedef struct
|
||||
{
|
||||
gboolean relative;
|
||||
GArray *path;
|
||||
char *str;
|
||||
} vfs_path_t;
|
||||
|
||||
typedef struct
|
||||
@ -62,7 +63,6 @@ void vfs_path_remove_element_by_index (vfs_path_t * vpath, int element_index);
|
||||
void vfs_path_free (vfs_path_t * path);
|
||||
int vfs_path_elements_count (const vfs_path_t * path);
|
||||
|
||||
char *vfs_path_to_str (const vfs_path_t * path);
|
||||
char *vfs_path_to_str_elements_count (const vfs_path_t * path, int elements_count);
|
||||
char *vfs_path_to_str_flags (const vfs_path_t * vpath, int elements_count, vfs_path_flag_t flags);
|
||||
vfs_path_t *vfs_path_from_str (const char *path_str);
|
||||
@ -128,4 +128,23 @@ vfs_path_get_last_path_vfs (const vfs_path_t * vpath)
|
||||
return (element != NULL) ? element->class : NULL;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Convert vfs_path_t to string representation.
|
||||
*
|
||||
* @param vpath pointer to vfs_path_t object
|
||||
*
|
||||
* @return pointer to newly created string.
|
||||
*/
|
||||
|
||||
static inline char *
|
||||
vfs_path_as_str (const vfs_path_t * vpath)
|
||||
{
|
||||
if (vpath == NULL)
|
||||
return NULL;
|
||||
return vpath->str;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#endif
|
||||
|
@ -2,12 +2,13 @@
|
||||
Virtual File System switch code
|
||||
|
||||
Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||
2007, 2011
|
||||
2007, 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by: 1995 Miguel de Icaza
|
||||
Jakub Jelinek, 1995
|
||||
Pavel Machek, 1998
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -370,7 +371,7 @@ vfs_translate_path_n (const char *path)
|
||||
char *
|
||||
vfs_get_current_dir (void)
|
||||
{
|
||||
return vfs_path_to_str (current_path);
|
||||
return g_strdup (current_path->str);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -579,8 +580,11 @@ vfs_setup_cwd (void)
|
||||
char *
|
||||
_vfs_get_cwd (void)
|
||||
{
|
||||
const vfs_path_t *current_dir_vpath;
|
||||
|
||||
vfs_setup_cwd ();
|
||||
return vfs_path_to_str (vfs_get_raw_current_dir ());
|
||||
current_dir_vpath = vfs_get_raw_current_dir ();
|
||||
return g_strdup (vfs_path_as_str (current_dir_vpath));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
Copyright (C) 2007, 2010, 2011, 2012
|
||||
Copyright (C) 2007, 2010, 2011, 2012, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Daniel Borca <dborca@yahoo.com>, 2007
|
||||
Slava Zanko <slavazanko@gmail.com>, 2010
|
||||
Slava Zanko <slavazanko@gmail.com>, 2010, 2013
|
||||
Andrew Borodin <aborodin@vmail.ru>, 2010, 2012
|
||||
Ilia Maslakov <il.smind@gmail.com>, 2010
|
||||
|
||||
@ -172,7 +172,7 @@ open_temp (void **name)
|
||||
_("Cannot create temporary diff file\n%s"), unix_error_string (errno));
|
||||
return -1;
|
||||
}
|
||||
*name = vfs_path_to_str (diff_file_name);
|
||||
*name = g_strdup (vfs_path_as_str (diff_file_name));
|
||||
vfs_path_free (diff_file_name);
|
||||
return fd;
|
||||
}
|
||||
@ -3618,21 +3618,11 @@ dview_diff_cmd (const void *f0, const void *f1)
|
||||
|
||||
GET_FILE_AND_STAMP (0);
|
||||
GET_FILE_AND_STAMP (1);
|
||||
if (real_file0 != NULL && real_file1 != NULL)
|
||||
{
|
||||
char *real_file0_str, *real_file1_str;
|
||||
char *file0_str, *file1_str;
|
||||
|
||||
real_file0_str = vfs_path_to_str (real_file0);
|
||||
real_file1_str = vfs_path_to_str (real_file1);
|
||||
file0_str = vfs_path_to_str (file0);
|
||||
file1_str = vfs_path_to_str (file1);
|
||||
rv = diff_view (real_file0_str, real_file1_str, file0_str, file1_str);
|
||||
g_free (real_file0_str);
|
||||
g_free (real_file1_str);
|
||||
g_free (file0_str);
|
||||
g_free (file1_str);
|
||||
}
|
||||
if (real_file0 != NULL && real_file1 != NULL)
|
||||
rv = diff_view (vfs_path_as_str (real_file0), vfs_path_as_str (real_file1),
|
||||
vfs_path_as_str (file0), vfs_path_as_str (file1));
|
||||
|
||||
UNGET_FILE (1);
|
||||
UNGET_FILE (0);
|
||||
}
|
||||
|
@ -211,11 +211,10 @@ edit_load_file_fast (WEdit * edit, const vfs_path_t * filename_vpath)
|
||||
file = mc_open (filename_vpath, O_RDONLY | O_BINARY);
|
||||
if (file == -1)
|
||||
{
|
||||
gchar *errmsg, *filename;
|
||||
gchar *errmsg;
|
||||
|
||||
filename = vfs_path_to_str (filename_vpath);
|
||||
errmsg = g_strdup_printf (_("Cannot open %s for reading"), filename);
|
||||
g_free (filename);
|
||||
errmsg =
|
||||
g_strdup_printf (_("Cannot open %s for reading"), vfs_path_as_str (filename_vpath));
|
||||
edit_error_dialog (_("Error"), errmsg);
|
||||
g_free (errmsg);
|
||||
return FALSE;
|
||||
@ -245,11 +244,9 @@ edit_load_file_fast (WEdit * edit, const vfs_path_t * filename_vpath)
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
gchar *errmsg, *filename;
|
||||
gchar *errmsg;
|
||||
|
||||
filename = vfs_path_to_str (filename_vpath);
|
||||
errmsg = g_strdup_printf (_("Error reading %s"), filename);
|
||||
g_free (filename);
|
||||
errmsg = g_strdup_printf (_("Error reading %s"), vfs_path_as_str (filename_vpath));
|
||||
edit_error_dialog (_("Error"), errmsg);
|
||||
g_free (errmsg);
|
||||
}
|
||||
@ -264,24 +261,18 @@ static int
|
||||
edit_find_filter (const vfs_path_t * filename_vpath)
|
||||
{
|
||||
size_t i, l, e;
|
||||
char *filename;
|
||||
|
||||
if (filename_vpath == NULL)
|
||||
return -1;
|
||||
|
||||
filename = vfs_path_to_str (filename_vpath);
|
||||
l = strlen (filename);
|
||||
l = strlen (vfs_path_as_str (filename_vpath));
|
||||
for (i = 0; i < G_N_ELEMENTS (all_filters); i++)
|
||||
{
|
||||
e = strlen (all_filters[i].extension);
|
||||
if (l > e)
|
||||
if (!strcmp (all_filters[i].extension, filename + l - e))
|
||||
{
|
||||
g_free (filename);
|
||||
if (!strcmp (all_filters[i].extension, vfs_path_as_str (filename_vpath) + l - e))
|
||||
return i;
|
||||
}
|
||||
}
|
||||
g_free (filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -291,15 +282,13 @@ static char *
|
||||
edit_get_filter (const vfs_path_t * filename_vpath)
|
||||
{
|
||||
int i;
|
||||
char *p, *quoted_name, *filename;
|
||||
char *p, *quoted_name;
|
||||
|
||||
i = edit_find_filter (filename_vpath);
|
||||
if (i < 0)
|
||||
return NULL;
|
||||
|
||||
filename = vfs_path_to_str (filename_vpath);
|
||||
quoted_name = name_quote (filename, 0);
|
||||
g_free (filename);
|
||||
quoted_name = name_quote (vfs_path_as_str (filename_vpath), 0);
|
||||
p = g_strdup_printf (all_filters[i].read, quoted_name);
|
||||
g_free (quoted_name);
|
||||
return p;
|
||||
@ -347,11 +336,8 @@ check_file_access (WEdit * edit, const vfs_path_t * filename_vpath, struct stat
|
||||
file = mc_open (filename_vpath, O_NONBLOCK | O_RDONLY | O_BINARY | O_CREAT | O_EXCL, 0666);
|
||||
if (file < 0)
|
||||
{
|
||||
char *filename;
|
||||
|
||||
filename = vfs_path_to_str (filename_vpath);
|
||||
errmsg = g_strdup_printf (_("Cannot open %s for reading"), filename);
|
||||
g_free (filename);
|
||||
errmsg =
|
||||
g_strdup_printf (_("Cannot open %s for reading"), vfs_path_as_str (filename_vpath));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -362,22 +348,17 @@ check_file_access (WEdit * edit, const vfs_path_t * filename_vpath, struct stat
|
||||
/* Check what we have opened */
|
||||
if (mc_fstat (file, st) < 0)
|
||||
{
|
||||
char *filename;
|
||||
|
||||
filename = vfs_path_to_str (filename_vpath);
|
||||
errmsg = g_strdup_printf (_("Cannot get size/permissions for %s"), filename);
|
||||
g_free (filename);
|
||||
errmsg =
|
||||
g_strdup_printf (_("Cannot get size/permissions for %s"),
|
||||
vfs_path_as_str (filename_vpath));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* We want to open regular files only */
|
||||
if (!S_ISREG (st->st_mode))
|
||||
{
|
||||
char *filename;
|
||||
|
||||
filename = vfs_path_to_str (filename_vpath);
|
||||
errmsg = g_strdup_printf (_("\"%s\" is not a regular file"), filename);
|
||||
g_free (filename);
|
||||
errmsg =
|
||||
g_strdup_printf (_("\"%s\" is not a regular file"), vfs_path_as_str (filename_vpath));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -389,13 +370,7 @@ check_file_access (WEdit * edit, const vfs_path_t * filename_vpath, struct stat
|
||||
edit->delete_file = 0;
|
||||
|
||||
if (st->st_size >= SIZE_LIMIT)
|
||||
{
|
||||
char *filename;
|
||||
|
||||
filename = vfs_path_to_str (filename_vpath);
|
||||
errmsg = g_strdup_printf (_("File \"%s\" is too large"), filename);
|
||||
g_free (filename);
|
||||
}
|
||||
errmsg = g_strdup_printf (_("File \"%s\" is too large"), vfs_path_as_str (filename_vpath));
|
||||
|
||||
cleanup:
|
||||
(void) mc_close (file);
|
||||
|
@ -446,7 +446,6 @@ static vfs_path_t *
|
||||
edit_get_save_file_as (WEdit * edit)
|
||||
{
|
||||
static LineBreaks cur_lb = LB_ASIS;
|
||||
char *filename;
|
||||
char *filename_res;
|
||||
vfs_path_t *ret_vpath = NULL;
|
||||
|
||||
@ -457,12 +456,11 @@ edit_get_save_file_as (WEdit * edit)
|
||||
N_("&Macintosh format (CR)")
|
||||
};
|
||||
|
||||
filename = vfs_path_to_str (edit->filename_vpath);
|
||||
|
||||
{
|
||||
quick_widget_t quick_widgets[] = {
|
||||
/* *INDENT-OFF* */
|
||||
QUICK_LABELED_INPUT (N_("Enter file name:"), input_label_above, filename, "save-as",
|
||||
QUICK_LABELED_INPUT (N_("Enter file name:"), input_label_above,
|
||||
vfs_path_as_str (edit->filename_vpath), "save-as",
|
||||
&filename_res, NULL, FALSE, FALSE, INPUT_COMPLETE_FILENAMES),
|
||||
QUICK_SEPARATOR (TRUE),
|
||||
QUICK_LABEL (N_("Change line breaks to:"), NULL),
|
||||
@ -490,8 +488,6 @@ edit_get_save_file_as (WEdit * edit)
|
||||
}
|
||||
}
|
||||
|
||||
g_free (filename);
|
||||
|
||||
return ret_vpath;
|
||||
}
|
||||
|
||||
@ -2056,12 +2052,10 @@ edit_save_confirm_cmd (WEdit * edit)
|
||||
|
||||
if (edit_confirm_save)
|
||||
{
|
||||
char *filename;
|
||||
gboolean ok;
|
||||
|
||||
filename = vfs_path_to_str (edit->filename_vpath);
|
||||
f = g_strdup_printf (_("Confirm save file: \"%s\""), filename);
|
||||
g_free (filename);
|
||||
f = g_strdup_printf (_("Confirm save file: \"%s\""),
|
||||
vfs_path_as_str (edit->filename_vpath));
|
||||
ok = (edit_query_dialog2 (_("Save file"), f, _("&Save"), _("&Cancel")) == 0);
|
||||
g_free (f);
|
||||
if (!ok)
|
||||
@ -2791,7 +2785,7 @@ edit_ok_to_exit (WEdit * edit)
|
||||
return TRUE;
|
||||
|
||||
if (edit->filename_vpath != NULL)
|
||||
fname = vfs_path_to_str (edit->filename_vpath);
|
||||
fname = g_strdup (vfs_path_as_str (edit->filename_vpath));
|
||||
#ifdef ENABLE_NLS
|
||||
else
|
||||
fname = g_strdup (_(fname));
|
||||
|
@ -2,12 +2,13 @@
|
||||
Editor text drawing.
|
||||
|
||||
Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2004, 2005, 2006,
|
||||
2007, 2011, 2012
|
||||
2007, 2011, 2012, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Paul Sheer, 1996, 1997
|
||||
Andrew Borodin <aborodin@vmail.ru> 2012
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -260,12 +261,10 @@ edit_status_window (WEdit * edit)
|
||||
if (cols > 5)
|
||||
{
|
||||
const char *fname = N_("NoName");
|
||||
char *full_fname = NULL;
|
||||
|
||||
if (edit->filename_vpath != NULL)
|
||||
{
|
||||
full_fname = vfs_path_to_str (edit->filename_vpath);
|
||||
fname = x_basename (full_fname);
|
||||
fname = x_basename (vfs_path_as_str (edit->filename_vpath));
|
||||
}
|
||||
#ifdef ENABLE_NLS
|
||||
else
|
||||
@ -274,7 +273,6 @@ edit_status_window (WEdit * edit)
|
||||
|
||||
edit_move (2, 0);
|
||||
tty_printf ("[%s]", str_term_trim (fname, w->cols - 8 - 6));
|
||||
g_free (full_fname);
|
||||
}
|
||||
|
||||
tty_getyx (&y, &x);
|
||||
|
@ -338,13 +338,9 @@ edit_window_list (const WDialog * h)
|
||||
if (e->filename_vpath == NULL)
|
||||
fname = g_strdup_printf ("%c [%s]", e->modified ? '*' : ' ', _("NoName"));
|
||||
else
|
||||
{
|
||||
char *fname2;
|
||||
|
||||
fname2 = vfs_path_to_str (e->filename_vpath);
|
||||
fname = g_strdup_printf ("%c%s", e->modified ? '*' : ' ', fname2);
|
||||
g_free (fname2);
|
||||
}
|
||||
fname =
|
||||
g_strdup_printf ("%c%s", e->modified ? '*' : ' ',
|
||||
vfs_path_as_str (e->filename_vpath));
|
||||
|
||||
listbox_add_item (listbox->list, LISTBOX_APPEND_AT_END, get_hotkey (i++),
|
||||
str_term_trim (fname, WIDGET (listbox->list)->cols - 2), NULL);
|
||||
@ -394,9 +390,11 @@ edit_get_title (const WDialog * h, size_t len)
|
||||
|
||||
len -= 4;
|
||||
|
||||
filename = vfs_path_to_str (edit->filename_vpath);
|
||||
if (filename == NULL)
|
||||
if (edit->filename_vpath == NULL)
|
||||
filename = g_strdup (_("[NoName]"));
|
||||
else
|
||||
filename = g_strdup (vfs_path_as_str (edit->filename_vpath));
|
||||
|
||||
file_label = str_term_trim (filename, len - str_term_width1 (_("Edit: ")));
|
||||
g_free (filename);
|
||||
|
||||
@ -1249,7 +1247,7 @@ edit_files (const GList * files)
|
||||
char *
|
||||
edit_get_file_name (const WEdit * edit)
|
||||
{
|
||||
return vfs_path_to_str (edit->filename_vpath);
|
||||
return g_strdup (vfs_path_as_str (edit->filename_vpath));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -2,12 +2,13 @@
|
||||
Editor syntax highlighting.
|
||||
|
||||
Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2004, 2005, 2006,
|
||||
2007, 2010, 2011
|
||||
2007, 2010, 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Paul Sheer, 1998
|
||||
Egmont Koblinger <egmont@gmail.com>, 2010
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -1484,15 +1485,9 @@ edit_load_syntax (WEdit * edit, char ***pnames, const char *type)
|
||||
|
||||
f = mc_config_get_full_path (EDIT_SYNTAX_FILE);
|
||||
if (edit != NULL)
|
||||
{
|
||||
char *tmp_f;
|
||||
|
||||
tmp_f = vfs_path_to_str (edit->filename_vpath);
|
||||
r = edit_read_syntax_file (edit, pnames, f, tmp_f,
|
||||
r = edit_read_syntax_file (edit, pnames, f, vfs_path_as_str (edit->filename_vpath),
|
||||
get_first_editor_line (edit),
|
||||
option_auto_syntax ? NULL : edit->syntax_type);
|
||||
g_free (tmp_f);
|
||||
}
|
||||
else
|
||||
r = edit_read_syntax_file (NULL, pnames, f, NULL, "", NULL);
|
||||
if (r == -1)
|
||||
|
@ -1,9 +1,12 @@
|
||||
/*
|
||||
Execution routines for GNU Midnight Commander
|
||||
|
||||
Copyright (C) 2003, 2004, 2005, 2007, 2011
|
||||
Copyright (C) 2003, 2004, 2005, 2007, 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander is free software: you can redistribute it
|
||||
@ -187,11 +190,8 @@ execute_prepare_with_vfs_arg (const vfs_path_t * filename_vpath, vfs_path_t ** l
|
||||
*localcopy_vpath = mc_getlocalcopy (filename_vpath);
|
||||
if (*localcopy_vpath == NULL)
|
||||
{
|
||||
char *filename;
|
||||
|
||||
filename = vfs_path_to_str (filename_vpath);
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot fetch a local copy of %s"), filename);
|
||||
g_free (filename);
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot fetch a local copy of %s"),
|
||||
vfs_path_as_str (filename_vpath));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -943,7 +943,11 @@ tree_box (const char *current_dir)
|
||||
WIDGET (bar)->y = LINES - 1;
|
||||
|
||||
if (run_dlg (dlg) == B_ENTER)
|
||||
val = vfs_path_to_str (tree_selected_name (mytree));
|
||||
{
|
||||
const vfs_path_t *selected_name;
|
||||
selected_name = tree_selected_name (mytree);
|
||||
val = g_strdup (vfs_path_as_str (selected_name));
|
||||
}
|
||||
|
||||
destroy_dlg (dlg);
|
||||
return val;
|
||||
@ -1066,41 +1070,30 @@ void
|
||||
symlink_dialog (const vfs_path_t * existing_vpath, const vfs_path_t * new_vpath,
|
||||
char **ret_existing, char **ret_new)
|
||||
{
|
||||
char *existing;
|
||||
char *new;
|
||||
|
||||
existing = vfs_path_to_str (existing_vpath);
|
||||
new = vfs_path_to_str (new_vpath);
|
||||
|
||||
{
|
||||
quick_widget_t quick_widgets[] = {
|
||||
quick_widget_t quick_widgets[] = {
|
||||
/* *INDENT-OFF* */
|
||||
QUICK_LABELED_INPUT (N_("Existing filename (filename symlink will point to):"),
|
||||
input_label_above,
|
||||
existing, "input-2", ret_existing, NULL, FALSE, FALSE, INPUT_COMPLETE_FILENAMES),
|
||||
vfs_path_as_str (existing_vpath), "input-2", ret_existing, NULL, FALSE, FALSE, INPUT_COMPLETE_FILENAMES),
|
||||
QUICK_SEPARATOR (FALSE),
|
||||
QUICK_LABELED_INPUT (N_("Symbolic link filename:"), input_label_above,
|
||||
new, "input-1", ret_new, NULL, FALSE, FALSE, INPUT_COMPLETE_FILENAMES),
|
||||
vfs_path_as_str (new_vpath), "input-1", ret_new, NULL, FALSE, FALSE, INPUT_COMPLETE_FILENAMES),
|
||||
QUICK_BUTTONS_OK_CANCEL,
|
||||
QUICK_END
|
||||
/* *INDENT-ON* */
|
||||
};
|
||||
};
|
||||
|
||||
quick_dialog_t qdlg = {
|
||||
-1, -1, 64,
|
||||
N_("Symbolic link"), "[File Menu]",
|
||||
quick_widgets, NULL, NULL
|
||||
};
|
||||
quick_dialog_t qdlg = {
|
||||
-1, -1, 64,
|
||||
N_("Symbolic link"), "[File Menu]",
|
||||
quick_widgets, NULL, NULL
|
||||
};
|
||||
|
||||
if (quick_dialog (&qdlg) == B_CANCEL)
|
||||
{
|
||||
*ret_new = NULL;
|
||||
*ret_existing = NULL;
|
||||
}
|
||||
if (quick_dialog (&qdlg) == B_CANCEL)
|
||||
{
|
||||
*ret_new = NULL;
|
||||
*ret_existing = NULL;
|
||||
}
|
||||
|
||||
g_free (existing);
|
||||
g_free (new);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -295,20 +295,15 @@ static int
|
||||
compare_files (const vfs_path_t * vpath1, const vfs_path_t * vpath2, off_t size)
|
||||
{
|
||||
int file1, file2;
|
||||
char *name;
|
||||
int result = -1; /* Different by default */
|
||||
|
||||
if (size == 0)
|
||||
return 0;
|
||||
|
||||
name = vfs_path_to_str (vpath1);
|
||||
file1 = open (name, O_RDONLY);
|
||||
g_free (name);
|
||||
file1 = open (vfs_path_as_str (vpath1), O_RDONLY);
|
||||
if (file1 >= 0)
|
||||
{
|
||||
name = vfs_path_to_str (vpath2);
|
||||
file2 = open (name, O_RDONLY);
|
||||
g_free (name);
|
||||
file2 = open (vfs_path_as_str (vpath2), O_RDONLY);
|
||||
if (file2 >= 0)
|
||||
{
|
||||
#ifdef HAVE_MMAP
|
||||
@ -1235,12 +1230,10 @@ hotlist_cmd (void)
|
||||
else
|
||||
{
|
||||
vfs_path_t *deprecated_vpath;
|
||||
char *cmd, *normalized_target;
|
||||
char *cmd;
|
||||
|
||||
deprecated_vpath = vfs_path_from_str_flags (target, VPF_USE_DEPRECATED_PARSER);
|
||||
normalized_target = vfs_path_to_str (deprecated_vpath);
|
||||
cmd = g_strconcat ("cd ", normalized_target, (char *) NULL);
|
||||
g_free (normalized_target);
|
||||
cmd = g_strconcat ("cd ", vfs_path_as_str (deprecated_vpath), (char *) NULL);
|
||||
vfs_path_free (deprecated_vpath);
|
||||
|
||||
do_cd_command (cmd);
|
||||
|
@ -5,9 +5,12 @@
|
||||
help from the program's callback.
|
||||
|
||||
Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||
2007, 2011
|
||||
2007, 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander is free software: you can redistribute it
|
||||
@ -399,8 +402,6 @@ do_cd_command (char *orig_cmd)
|
||||
}
|
||||
else if (strcmp (cmd + operand_pos, "..") == 0)
|
||||
{
|
||||
char *str_path;
|
||||
|
||||
if (vfs_path_elements_count (current_panel->cwd_vpath) != 1 ||
|
||||
strlen (vfs_path_get_by_index (current_panel->cwd_vpath, 0)->path) > 1)
|
||||
{
|
||||
@ -410,9 +411,7 @@ do_cd_command (char *orig_cmd)
|
||||
vfs_path_vtokens_get (tmp_vpath, 0, vfs_path_tokens_count (tmp_vpath) - 1);
|
||||
vfs_path_free (tmp_vpath);
|
||||
}
|
||||
str_path = vfs_path_to_str (current_panel->cwd_vpath);
|
||||
sync_tree (str_path);
|
||||
g_free (str_path);
|
||||
sync_tree (vfs_path_as_str (current_panel->cwd_vpath));
|
||||
}
|
||||
else if (cmd[operand_pos] == PATH_SEP)
|
||||
{
|
||||
@ -420,14 +419,11 @@ do_cd_command (char *orig_cmd)
|
||||
}
|
||||
else
|
||||
{
|
||||
char *str_path;
|
||||
vfs_path_t *new_vpath;
|
||||
|
||||
new_vpath = vfs_path_append_new (current_panel->cwd_vpath, cmd + operand_pos, NULL);
|
||||
str_path = vfs_path_to_str (new_vpath);
|
||||
sync_tree (vfs_path_as_str (new_vpath));
|
||||
vfs_path_free (new_vpath);
|
||||
sync_tree (str_path);
|
||||
g_free (str_path);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2,9 +2,12 @@
|
||||
Directory routines
|
||||
|
||||
Copyright (C) 1994, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||
2006, 2007, 2011
|
||||
2006, 2007, 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander is free software: you can redistribute it
|
||||
@ -554,7 +557,7 @@ do_load_dir (const vfs_path_t * vpath, dir_list * list, sortfn * sort, gboolean
|
||||
int status, link_to_dir, stale_link;
|
||||
int next_free = 0;
|
||||
struct stat st;
|
||||
char *path;
|
||||
const char *vpath_str;
|
||||
|
||||
/* ".." (if any) must be the first entry in the list */
|
||||
if (!set_zero_dir (list))
|
||||
@ -573,11 +576,10 @@ do_load_dir (const vfs_path_t * vpath, dir_list * list, sortfn * sort, gboolean
|
||||
|
||||
tree_store_start_check (vpath);
|
||||
|
||||
vpath_str = vfs_path_as_str (vpath);
|
||||
/* Do not add a ".." entry to the root directory */
|
||||
path = vfs_path_to_str (vpath);
|
||||
if ((path[0] == PATH_SEP) && (path[1] == '\0'))
|
||||
if ((vpath_str[0] == PATH_SEP) && (vpath_str[1] == '\0'))
|
||||
next_free--;
|
||||
g_free (path);
|
||||
|
||||
while ((dp = mc_readdir (dirp)) != NULL)
|
||||
{
|
||||
|
@ -2,12 +2,13 @@
|
||||
Extension dependent execution.
|
||||
|
||||
Copyright (C) 1994, 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||
2005, 2007, 2011
|
||||
2005, 2007, 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Jakub Jelinek, 1995
|
||||
Miguel de Icaza, 1994
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -366,13 +367,7 @@ exec_extension_view (void *target, char *cmd, const vfs_path_t * filename_vpath,
|
||||
if (target == NULL)
|
||||
mcview_viewer (cmd, filename_vpath, start_line);
|
||||
else
|
||||
{
|
||||
char *file_name;
|
||||
|
||||
file_name = vfs_path_to_str (filename_vpath);
|
||||
mcview_load ((mcview_t *) target, cmd, file_name, start_line);
|
||||
g_free (file_name);
|
||||
}
|
||||
mcview_load ((mcview_t *) target, cmd, vfs_path_as_str (filename_vpath), start_line);
|
||||
|
||||
if (changed_hex_mode && !mcview_altered_hex_mode)
|
||||
mcview_default_hex_mode = def_hex_mode;
|
||||
@ -478,13 +473,7 @@ exec_extension (void *target, const vfs_path_t * filename_vpath, const char *lc_
|
||||
* so we clean up after calling view().
|
||||
*/
|
||||
if (!run_view)
|
||||
{
|
||||
char *file_name;
|
||||
|
||||
file_name = vfs_path_to_str (script_vpath);
|
||||
fprintf (cmd_file, "\n/bin/rm -f %s\n", file_name);
|
||||
g_free (file_name);
|
||||
}
|
||||
fprintf (cmd_file, "\n/bin/rm -f %s\n", vfs_path_as_str (script_vpath));
|
||||
|
||||
fclose (cmd_file);
|
||||
|
||||
@ -495,14 +484,10 @@ exec_extension (void *target, const vfs_path_t * filename_vpath, const char *lc_
|
||||
}
|
||||
else
|
||||
{
|
||||
char *file_name;
|
||||
|
||||
file_name = vfs_path_to_str (script_vpath);
|
||||
/* Set executable flag on the command file ... */
|
||||
mc_chmod (script_vpath, S_IRWXU);
|
||||
/* ... but don't rely on it - run /bin/sh explicitly */
|
||||
cmd = g_strconcat ("/bin/sh ", file_name, (char *) NULL);
|
||||
g_free (file_name);
|
||||
cmd = g_strconcat ("/bin/sh ", vfs_path_as_str (script_vpath), (char *) NULL);
|
||||
}
|
||||
|
||||
if (run_view)
|
||||
@ -664,13 +649,10 @@ regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, int *have_
|
||||
localfile_vpath = mc_getlocalcopy (filename_vpath);
|
||||
if (localfile_vpath == NULL)
|
||||
{
|
||||
char *filename;
|
||||
|
||||
filename = vfs_path_to_str (filename_vpath);
|
||||
g_propagate_error (error,
|
||||
g_error_new (MC_ERROR, -1,
|
||||
_("Cannot fetch a local copy of %s"), filename));
|
||||
g_free (filename);
|
||||
_("Cannot fetch a local copy of %s"),
|
||||
vfs_path_as_str (filename_vpath)));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -791,7 +773,7 @@ int
|
||||
regex_command_for (void *target, const vfs_path_t * filename_vpath, const char *action,
|
||||
vfs_path_t ** script_vpath)
|
||||
{
|
||||
char *filename, *p, *q, *r, c;
|
||||
char *p, *q, *r, c;
|
||||
size_t file_len;
|
||||
gboolean found = FALSE;
|
||||
gboolean error_flag = FALSE;
|
||||
@ -893,7 +875,6 @@ regex_command_for (void *target, const vfs_path_t * filename_vpath, const char *
|
||||
|
||||
include_target = NULL;
|
||||
include_target_len = 0;
|
||||
filename = vfs_path_to_str (filename_vpath);
|
||||
file_len = vfs_path_len (filename_vpath);
|
||||
|
||||
for (p = data; *p != '\0'; p++)
|
||||
@ -941,13 +922,15 @@ regex_command_for (void *target, const vfs_path_t * filename_vpath, const char *
|
||||
{
|
||||
search->search_type = MC_SEARCH_T_REGEX;
|
||||
search->is_case_sensitive = !case_insense;
|
||||
found = mc_search_run (search, filename, 0, file_len, NULL);
|
||||
found =
|
||||
mc_search_run (search, vfs_path_as_str (filename_vpath), 0, file_len, NULL);
|
||||
mc_search_free (search);
|
||||
}
|
||||
}
|
||||
else if (strncmp (p, "directory/", 10) == 0)
|
||||
{
|
||||
if (S_ISDIR (mystat.st_mode) && mc_search (p + 10, filename, MC_SEARCH_T_REGEX))
|
||||
if (S_ISDIR (mystat.st_mode)
|
||||
&& mc_search (p + 10, vfs_path_as_str (filename_vpath), MC_SEARCH_T_REGEX))
|
||||
found = TRUE;
|
||||
}
|
||||
else if (strncmp (p, "shell/", 6) == 0)
|
||||
@ -964,12 +947,14 @@ regex_command_for (void *target, const vfs_path_t * filename_vpath, const char *
|
||||
|
||||
if (*p == '.' && file_len >= (size_t) (q - p))
|
||||
{
|
||||
if (cmp_func (p, filename + file_len - (q - p), q - p) == 0)
|
||||
if (cmp_func
|
||||
(p, vfs_path_as_str (filename_vpath) + file_len - (q - p), q - p) == 0)
|
||||
found = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((size_t) (q - p) == file_len && cmp_func (p, filename, q - p) == 0)
|
||||
if ((size_t) (q - p) == file_len
|
||||
&& cmp_func (p, vfs_path_as_str (filename_vpath), q - p) == 0)
|
||||
found = TRUE;
|
||||
}
|
||||
}
|
||||
@ -1066,7 +1051,6 @@ regex_command_for (void *target, const vfs_path_t * filename_vpath, const char *
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_free (filename);
|
||||
if (error_flag)
|
||||
ret = -1;
|
||||
return ret;
|
||||
|
@ -1030,15 +1030,11 @@ erase_file (FileOpTotalContext * tctx, FileOpContext * ctx, const vfs_path_t * v
|
||||
{
|
||||
int return_status;
|
||||
struct stat buf;
|
||||
char *s;
|
||||
|
||||
s = vfs_path_to_str (vpath);
|
||||
file_progress_show_deleting (ctx, s);
|
||||
file_progress_show_deleting (ctx, vfs_path_as_str (vpath));
|
||||
if (check_progress_buttons (ctx) == FILE_ABORT)
|
||||
{
|
||||
g_free (s);
|
||||
return FILE_ABORT;
|
||||
}
|
||||
|
||||
mc_refresh ();
|
||||
|
||||
if (tctx->progress_count != 0 && mc_lstat (vpath, &buf) != 0)
|
||||
@ -1049,19 +1045,15 @@ erase_file (FileOpTotalContext * tctx, FileOpContext * ctx, const vfs_path_t * v
|
||||
|
||||
while (mc_unlink (vpath) != 0 && !ctx->skip_all)
|
||||
{
|
||||
return_status = file_error (_("Cannot delete file \"%s\"\n%s"), s);
|
||||
return_status = file_error (_("Cannot delete file \"%s\"\n%s"), vfs_path_as_str (vpath));
|
||||
if (return_status == FILE_ABORT)
|
||||
{
|
||||
g_free (s);
|
||||
return return_status;
|
||||
}
|
||||
if (return_status == FILE_RETRY)
|
||||
continue;
|
||||
if (return_status == FILE_SKIPALL)
|
||||
ctx->skip_all = TRUE;
|
||||
break;
|
||||
}
|
||||
g_free (s);
|
||||
if (tctx->progress_count == 0)
|
||||
return FILE_CONT;
|
||||
return progress_update_one (tctx, ctx, buf.st_size);
|
||||
@ -1236,9 +1228,11 @@ panel_get_file (WPanel * panel)
|
||||
if (get_current_type () == view_tree)
|
||||
{
|
||||
WTree *tree;
|
||||
vfs_path_t *selected_name;
|
||||
|
||||
tree = (WTree *) get_panel_widget (get_current_index ());
|
||||
return vfs_path_to_str (tree_selected_name (tree));
|
||||
selected_name = tree_selected_name (tree);
|
||||
return g_strdup (vfs_path_as_str (selected_name));
|
||||
}
|
||||
|
||||
if (panel->marked != 0)
|
||||
@ -2416,13 +2410,8 @@ move_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
||||
lp = (struct link *) erase_list->data;
|
||||
|
||||
if (S_ISDIR (lp->st_mode))
|
||||
{
|
||||
char *src_path;
|
||||
|
||||
src_path = vfs_path_to_str (lp->src_vpath);
|
||||
return_status = erase_dir_iff_empty (ctx, src_path);
|
||||
g_free (src_path);
|
||||
}
|
||||
return_status = erase_dir_iff_empty (ctx, vfs_path_as_str (lp->src_vpath));
|
||||
else
|
||||
return_status = erase_file (tctx, ctx, lp->src_vpath);
|
||||
|
||||
@ -2451,9 +2440,6 @@ FileProgressStatus
|
||||
erase_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const vfs_path_t * s_vpath)
|
||||
{
|
||||
FileProgressStatus error;
|
||||
char *s;
|
||||
|
||||
s = vfs_path_to_str (s_vpath);
|
||||
|
||||
/*
|
||||
if (strcmp (s, "..") == 0)
|
||||
@ -2463,12 +2449,9 @@ erase_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const vfs_path_t * s_
|
||||
return FILE_SKIP;
|
||||
*/
|
||||
|
||||
file_progress_show_deleting (ctx, s);
|
||||
if (check_progress_buttons (ctx) == FILE_ABORT)
|
||||
{
|
||||
g_free (s);
|
||||
return FILE_ABORT;
|
||||
}
|
||||
file_progress_show_deleting (ctx, vfs_path_as_str (s_vpath));
|
||||
return FILE_ABORT;
|
||||
|
||||
mc_refresh ();
|
||||
|
||||
/* The old way to detect a non empty directory was:
|
||||
@ -2481,24 +2464,19 @@ erase_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const vfs_path_t * s_
|
||||
error = check_dir_is_empty (s_vpath);
|
||||
if (error == 0)
|
||||
{ /* not empty */
|
||||
error = query_recursive (ctx, s);
|
||||
error = query_recursive (ctx, vfs_path_as_str (s_vpath));
|
||||
if (error == FILE_CONT)
|
||||
error = recursive_erase (tctx, ctx, s);
|
||||
g_free (s);
|
||||
error = recursive_erase (tctx, ctx, vfs_path_as_str (s_vpath));
|
||||
return error;
|
||||
}
|
||||
|
||||
while (my_rmdir (s) == -1 && !ctx->skip_all)
|
||||
while (my_rmdir (vfs_path_as_str (s_vpath)) == -1 && !ctx->skip_all)
|
||||
{
|
||||
error = file_error (_("Cannot remove directory \"%s\"\n%s"), s);
|
||||
error = file_error (_("Cannot remove directory \"%s\"\n%s"), vfs_path_as_str (s_vpath));
|
||||
if (error != FILE_RETRY)
|
||||
{
|
||||
g_free (s);
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
g_free (s);
|
||||
return FILE_CONT;
|
||||
}
|
||||
|
||||
@ -2581,17 +2559,14 @@ compute_dir_size_update_ui (void *ui, const vfs_path_t * dirname_vpath, size_t d
|
||||
ComputeDirSizeUI *this = (ComputeDirSizeUI *) ui;
|
||||
int c;
|
||||
Gpm_Event event;
|
||||
char *dirname;
|
||||
char buffer[BUF_1K];
|
||||
|
||||
if (ui == NULL)
|
||||
return FILE_CONT;
|
||||
|
||||
dirname = vfs_path_to_str (dirname_vpath);
|
||||
g_snprintf (buffer, sizeof (buffer), _("%s\nDirectories: %zd, total size: %s"),
|
||||
str_trunc (dirname, WIDGET (this->dlg)->cols - 6), dir_count,
|
||||
size_trunc_sep (total_size, panels_options.kilobyte_si));
|
||||
g_free (dirname);
|
||||
str_trunc (vfs_path_as_str (dirname_vpath), WIDGET (this->dlg)->cols - 6),
|
||||
dir_count, size_trunc_sep (total_size, panels_options.kilobyte_si));
|
||||
label_set_text (this->dirname, buffer);
|
||||
|
||||
event.x = -1; /* Don't show the GPM cursor */
|
||||
@ -2658,7 +2633,6 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
||||
char *source = NULL;
|
||||
#ifdef WITH_FULL_PATHS
|
||||
vfs_path_t *source_with_vpath = NULL;
|
||||
char *source_with_path_str = NULL;
|
||||
#else
|
||||
#define source_with_path source
|
||||
#endif /* !WITH_FULL_PATHS */
|
||||
@ -2740,9 +2714,9 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
||||
if (force_single)
|
||||
tmp_dest_dir = g_strdup (source);
|
||||
else if (get_other_type () == view_listing)
|
||||
tmp_dest_dir = vfs_path_to_str (other_panel->cwd_vpath);
|
||||
tmp_dest_dir = g_strdup (vfs_path_as_str (other_panel->cwd_vpath));
|
||||
else
|
||||
tmp_dest_dir = vfs_path_to_str (panel->cwd_vpath);
|
||||
tmp_dest_dir = g_strdup (vfs_path_as_str (panel->cwd_vpath));
|
||||
/*
|
||||
* Add trailing backslash only when do non-local ops.
|
||||
* It saves user from occasional file renames (when destination
|
||||
@ -2823,11 +2797,10 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
||||
if (do_bg)
|
||||
{
|
||||
int v;
|
||||
char *cwd_str;
|
||||
|
||||
cwd_str = vfs_path_to_str (panel->cwd_vpath);
|
||||
v = do_background (ctx, g_strconcat (op_names[operation], ": ", cwd_str, (char *) NULL));
|
||||
g_free (cwd_str);
|
||||
v = do_background (ctx,
|
||||
g_strconcat (op_names[operation], ": ",
|
||||
vfs_path_as_str (panel->cwd_vpath), (char *) NULL));
|
||||
if (v == -1)
|
||||
message (D_ERROR, MSG_ERROR, _("Sorry, I could not put the job in background"));
|
||||
|
||||
@ -2868,7 +2841,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
||||
|
||||
if ((vfs_path_tokens_count (panel->cwd_vpath) != 0)
|
||||
&& (mc_setctl (panel->cwd_vpath, VFS_SETCTL_STALE_DATA, GUINT_TO_POINTER (1)) != 0))
|
||||
save_cwd = vfs_path_to_str (panel->cwd_vpath);
|
||||
save_cwd = g_strdup (vfs_path_as_str (panel->cwd_vpath));
|
||||
|
||||
/* Now, let's do the job */
|
||||
|
||||
@ -2899,10 +2872,9 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
||||
source_with_vpath = vfs_path_from_str (source);
|
||||
else
|
||||
source_with_vpath = vfs_path_append_new (panel->cwd_vpath, source, (char *) NULL);
|
||||
source_with_path_str = vfs_path_to_str (source_with_vpath);
|
||||
#endif /* WITH_FULL_PATHS */
|
||||
if (panel_operate_init_totals (operation, panel, source_with_path_str, ctx, dialog_type) ==
|
||||
FILE_CONT)
|
||||
if (panel_operate_init_totals
|
||||
(operation, panel, vfs_path_as_str (source_with_vpath), ctx, dialog_type) == FILE_CONT)
|
||||
{
|
||||
if (operation == OP_DELETE)
|
||||
{
|
||||
@ -2913,7 +2885,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = transform_source (ctx, source_with_path_str);
|
||||
temp = transform_source (ctx, vfs_path_as_str (source_with_vpath));
|
||||
if (temp == NULL)
|
||||
value = transform_error;
|
||||
else
|
||||
@ -2943,17 +2915,23 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
||||
ctx->stat_func (source_with_vpath, &src_stat);
|
||||
|
||||
if (S_ISDIR (src_stat.st_mode))
|
||||
value = copy_dir_dir (tctx, ctx, source_with_path_str, dest,
|
||||
TRUE, FALSE, FALSE, NULL);
|
||||
value =
|
||||
copy_dir_dir (tctx, ctx, vfs_path_as_str (source_with_vpath),
|
||||
dest, TRUE, FALSE, FALSE, NULL);
|
||||
else
|
||||
value = copy_file_file (tctx, ctx, source_with_path_str, dest);
|
||||
value =
|
||||
copy_file_file (tctx, ctx, vfs_path_as_str (source_with_vpath),
|
||||
dest);
|
||||
break;
|
||||
|
||||
case OP_MOVE:
|
||||
if (S_ISDIR (src_stat.st_mode))
|
||||
value = move_dir_dir (tctx, ctx, source_with_path_str, dest);
|
||||
value =
|
||||
move_dir_dir (tctx, ctx, vfs_path_as_str (source_with_vpath), dest);
|
||||
else
|
||||
value = move_file_file (tctx, ctx, source_with_path_str, dest);
|
||||
value =
|
||||
move_file_file (tctx, ctx, vfs_path_as_str (source_with_vpath),
|
||||
dest);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -3001,14 +2979,12 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
||||
src_stat = panel->dir.list[i].st;
|
||||
|
||||
#ifdef WITH_FULL_PATHS
|
||||
g_free (source_with_path_str);
|
||||
vfs_path_free (source_with_vpath);
|
||||
if (g_path_is_absolute (source2))
|
||||
source_with_vpath = vfs_path_from_str (source2);
|
||||
else
|
||||
source_with_vpath =
|
||||
vfs_path_append_new (panel->cwd_vpath, source2, (char *) NULL);
|
||||
source_with_path_str = vfs_path_to_str (source_with_vpath);
|
||||
#endif /* WITH_FULL_PATHS */
|
||||
|
||||
if (operation == OP_DELETE)
|
||||
@ -3020,12 +2996,12 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = transform_source (ctx, source_with_path_str);
|
||||
temp = transform_source (ctx, vfs_path_as_str (source_with_vpath));
|
||||
if (temp == NULL)
|
||||
value = transform_error;
|
||||
else
|
||||
{
|
||||
char *temp2, *temp3, *repl_dest;
|
||||
char *temp2, *temp3, *repl_dest, *source_with_path_str;
|
||||
|
||||
repl_dest = mc_search_prepare_replace_str2 (ctx->search_handle, dest);
|
||||
if (ctx->search_handle->error != MC_SEARCH_E_OK)
|
||||
@ -3038,9 +3014,8 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
||||
temp2 = mc_build_filename (repl_dest, temp, NULL);
|
||||
g_free (temp);
|
||||
g_free (repl_dest);
|
||||
temp3 = source_with_path_str;
|
||||
source_with_path_str = strutils_shell_unescape (source_with_path_str);
|
||||
g_free (temp3);
|
||||
source_with_path_str =
|
||||
strutils_shell_unescape (vfs_path_as_str (source_with_vpath));
|
||||
temp3 = temp2;
|
||||
temp2 = strutils_shell_unescape (temp2);
|
||||
g_free (temp3);
|
||||
@ -3124,7 +3099,6 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
|
||||
linklist = free_linklist (linklist);
|
||||
dest_dirs = free_linklist (dest_dirs);
|
||||
#ifdef WITH_FULL_PATHS
|
||||
g_free (source_with_path_str);
|
||||
vfs_path_free (source_with_vpath);
|
||||
#endif /* WITH_FULL_PATHS */
|
||||
g_free (dest);
|
||||
|
@ -21,7 +21,7 @@
|
||||
Jakub Jelinek, 1995, 1996
|
||||
Norbert Warmuth, 1997
|
||||
Pavel Machek, 1998
|
||||
Slava Zanko, 2009-2012
|
||||
Slava Zanko, 2009, 2010, 2011, 2012, 2013
|
||||
Andrew Borodin <aborodin@vmail.ru>, 2009, 2010, 2011, 2012, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
@ -1031,12 +1031,9 @@ file_progress_show_target (FileOpContext * ctx, const vfs_path_t * s_vpath)
|
||||
|
||||
if (s_vpath != NULL)
|
||||
{
|
||||
char *s;
|
||||
|
||||
s = vfs_path_to_str (s_vpath);
|
||||
label_set_text (ui->file_label[1], _("Target"));
|
||||
label_set_text (ui->file_string[1], truncFileStringSecure (ui->op_dlg, s));
|
||||
g_free (s);
|
||||
label_set_text (ui->file_string[1],
|
||||
truncFileStringSecure (ui->op_dlg, vfs_path_as_str (s_vpath)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3,12 +3,13 @@
|
||||
tree about the changes made to the directory
|
||||
structure.
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Author:
|
||||
Janne Kukonlehto
|
||||
Miguel de Icaza
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -110,7 +111,7 @@ my_mkdir_rec (char *s, mode_t mode)
|
||||
vfs_path_t *vpath;
|
||||
|
||||
vpath = vfs_path_from_str (p);
|
||||
q = vfs_path_to_str (vpath);
|
||||
q = g_strdup (vfs_path_as_str (vpath));
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
g_free (p);
|
||||
@ -136,13 +137,8 @@ my_mkdir (const vfs_path_t * s_vpath, mode_t mode)
|
||||
result = mc_mkdir (s_vpath, mode);
|
||||
|
||||
if (result != 0)
|
||||
{
|
||||
char *p;
|
||||
result = my_mkdir_rec (vfs_path_as_str (s_vpath), mode);
|
||||
|
||||
p = vfs_path_to_str (s_vpath);
|
||||
result = my_mkdir_rec (p, mode);
|
||||
g_free (p);
|
||||
}
|
||||
if (result == 0)
|
||||
{
|
||||
vfs_path_t *my_s;
|
||||
|
@ -2,11 +2,12 @@
|
||||
Find file command for the Midnight Commander
|
||||
|
||||
Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||
2006, 2007, 2011
|
||||
2006, 2007, 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Miguel de Icaza, 1995
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -716,7 +717,7 @@ find_parameters (char **start_dir, ssize_t * start_dir_len,
|
||||
|
||||
temp_dir = in_start->buffer;
|
||||
if ((temp_dir[0] == '\0') || ((temp_dir[0] == '.') && (temp_dir[1] == '\0')))
|
||||
temp_dir = vfs_path_to_str (current_panel->cwd_vpath);
|
||||
temp_dir = g_strdup (vfs_path_as_str (current_panel->cwd_vpath));
|
||||
else
|
||||
temp_dir = g_strdup (temp_dir);
|
||||
|
||||
@ -768,7 +769,7 @@ find_parameters (char **start_dir, ssize_t * start_dir_len,
|
||||
|
||||
if (s[0] == '.' && s[1] == '\0')
|
||||
{
|
||||
*start_dir = vfs_path_to_str (current_panel->cwd_vpath);
|
||||
*start_dir = g_strdup (vfs_path_as_str (current_panel->cwd_vpath));
|
||||
/* FIXME: is current_panel->cwd_vpath canonicalized? */
|
||||
/* relative paths will be used in panelization */
|
||||
*start_dir_len = (ssize_t) strlen (*start_dir);
|
||||
@ -782,12 +783,10 @@ find_parameters (char **start_dir, ssize_t * start_dir_len,
|
||||
else
|
||||
{
|
||||
/* relative paths will be used in panelization */
|
||||
char *cwd_str;
|
||||
|
||||
cwd_str = vfs_path_to_str (current_panel->cwd_vpath);
|
||||
*start_dir = mc_build_filename (cwd_str, s, (char *) NULL);
|
||||
*start_dir_len = (ssize_t) strlen (cwd_str);
|
||||
g_free (cwd_str);
|
||||
*start_dir =
|
||||
mc_build_filename (vfs_path_as_str (current_panel->cwd_vpath), s,
|
||||
(char *) NULL);
|
||||
*start_dir_len = (ssize_t) strlen (vfs_path_as_str (current_panel->cwd_vpath));
|
||||
g_free (s);
|
||||
}
|
||||
|
||||
@ -1268,12 +1267,9 @@ do_search (WDialog * h)
|
||||
|
||||
/* handle absolute ignore dirs here */
|
||||
{
|
||||
char *tmp;
|
||||
gboolean ok;
|
||||
|
||||
tmp = vfs_path_to_str (tmp_vpath);
|
||||
ok = find_ignore_dir_search (tmp);
|
||||
g_free (tmp);
|
||||
ok = find_ignore_dir_search (vfs_path_as_str (tmp_vpath));
|
||||
if (!ok)
|
||||
break;
|
||||
}
|
||||
@ -1283,7 +1279,7 @@ do_search (WDialog * h)
|
||||
}
|
||||
|
||||
g_free (directory);
|
||||
directory = vfs_path_to_str (tmp_vpath);
|
||||
directory = g_strdup (vfs_path_as_str (tmp_vpath));
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
|
@ -2,9 +2,12 @@
|
||||
Panel managing.
|
||||
|
||||
Copyright (C) 1994, 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||
2005, 2007, 2011
|
||||
2005, 2007, 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander is free software: you can redistribute it
|
||||
@ -121,13 +124,7 @@ info_show_info (WInfo * info)
|
||||
if (get_current_type () != view_listing)
|
||||
return;
|
||||
|
||||
{
|
||||
char *cwd_str;
|
||||
|
||||
cwd_str = vfs_path_to_str (current_panel->cwd_vpath);
|
||||
my_statfs (&myfs_stats, cwd_str);
|
||||
g_free (cwd_str);
|
||||
}
|
||||
my_statfs (&myfs_stats, vfs_path_as_str (current_panel->cwd_vpath));
|
||||
|
||||
st = current_panel->dir.list[current_panel->selected].st;
|
||||
|
||||
|
@ -2,13 +2,14 @@
|
||||
Panel layout module for the Midnight Commander
|
||||
|
||||
Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||
2006, 2007, 2009, 2011, 2012
|
||||
2006, 2007, 2009, 2011, 2012, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Janne Kukonlehto, 1995
|
||||
Miguel de Icaza, 1995
|
||||
Andrew Borodin <aborodin@vmail.ru>, 2011, 2012
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -1262,7 +1263,7 @@ save_panel_dir (int idx)
|
||||
|
||||
g_free (panels[idx].last_saved_dir); /* last path no needed */
|
||||
/* Because path can be nonlocal */
|
||||
panels[idx].last_saved_dir = vfs_path_to_str (w->cwd_vpath);
|
||||
panels[idx].last_saved_dir = g_strdup (vfs_path_as_str (w->cwd_vpath));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1283,7 +1284,12 @@ get_panel_dir_for (const WPanel * widget)
|
||||
return g_strdup (".");
|
||||
|
||||
if (get_display_type (i) == view_listing)
|
||||
return vfs_path_to_str (((WPanel *) get_panel_widget (i))->cwd_vpath);
|
||||
{
|
||||
vfs_path_t *cwd_vpath;
|
||||
|
||||
cwd_vpath = ((WPanel *) get_panel_widget (i))->cwd_vpath;
|
||||
return g_strdup (vfs_path_as_str (cwd_vpath));
|
||||
}
|
||||
|
||||
return g_strdup (panels[i].last_saved_dir);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
Main dialog (file panels) of the Midnight Commander
|
||||
|
||||
Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011
|
||||
2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
@ -10,6 +10,7 @@
|
||||
Janne Kukonlehto, 1994, 1995
|
||||
Norbert Warmuth, 1997
|
||||
Andrew Borodin <aborodin@vmail.ru>, 2009, 2010
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -684,28 +685,22 @@ create_panels (void)
|
||||
static void
|
||||
put_current_path (void)
|
||||
{
|
||||
char *cwd_path;
|
||||
vfs_path_t *cwd_vpath;
|
||||
|
||||
if (!command_prompt)
|
||||
return;
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
{
|
||||
vfs_path_t *cwd_vpath;
|
||||
|
||||
cwd_vpath = remove_encoding_from_path (current_panel->cwd_vpath);
|
||||
cwd_path = vfs_path_to_str (cwd_vpath);
|
||||
vfs_path_free (cwd_vpath);
|
||||
}
|
||||
cwd_vpath = remove_encoding_from_path (current_panel->cwd_vpath);
|
||||
#else
|
||||
cwd_path = vfs_path_to_str (current_panel->cwd_vpath);
|
||||
cwd_vpath = vfs_path_clone (current_panel->cwd_vpath);
|
||||
#endif
|
||||
|
||||
command_insert (cmdline, cwd_path, FALSE);
|
||||
if (cwd_path[strlen (cwd_path) - 1] != PATH_SEP)
|
||||
command_insert (cmdline, vfs_path_as_str (cwd_vpath), FALSE);
|
||||
if (cwd_vpath->str[strlen (vfs_path_as_str (cwd_vpath)) - 1] != PATH_SEP)
|
||||
command_insert (cmdline, PATH_SEP_STR, FALSE);
|
||||
|
||||
g_free (cwd_path);
|
||||
vfs_path_free (cwd_vpath);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -713,7 +708,7 @@ put_current_path (void)
|
||||
static void
|
||||
put_other_path (void)
|
||||
{
|
||||
char *cwd_path;
|
||||
vfs_path_t *cwd_vpath;
|
||||
|
||||
if (get_other_type () != view_listing)
|
||||
return;
|
||||
@ -722,22 +717,16 @@ put_other_path (void)
|
||||
return;
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
{
|
||||
vfs_path_t *cwd_vpath;
|
||||
|
||||
cwd_vpath = remove_encoding_from_path (other_panel->cwd_vpath);
|
||||
cwd_path = vfs_path_to_str (cwd_vpath);
|
||||
vfs_path_free (cwd_vpath);
|
||||
}
|
||||
cwd_vpath = remove_encoding_from_path (other_panel->cwd_vpath);
|
||||
#else
|
||||
cwd_path = vfs_path_to_str (other_panel->cwd_vpath);
|
||||
cwd_vpath = vfs_path_clone (other_panel->cwd_vpath);
|
||||
#endif
|
||||
|
||||
command_insert (cmdline, cwd_path, FALSE);
|
||||
if (cwd_path[strlen (cwd_path) - 1] != PATH_SEP)
|
||||
command_insert (cmdline, vfs_path_as_str (cwd_vpath), FALSE);
|
||||
if (cwd_vpath->str[strlen (vfs_path_as_str (cwd_vpath)) - 1] != PATH_SEP)
|
||||
command_insert (cmdline, PATH_SEP_STR, FALSE);
|
||||
|
||||
g_free (cwd_path);
|
||||
vfs_path_free (cwd_vpath);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -794,9 +783,12 @@ put_prog_name (void)
|
||||
|
||||
if (get_current_type () == view_tree)
|
||||
{
|
||||
WTree *tree = (WTree *) get_panel_widget (get_current_index ());
|
||||
WTree *tree;
|
||||
vfs_path_t *selected_name;
|
||||
|
||||
tmp = vfs_path_to_str (tree_selected_name (tree));
|
||||
tree = (WTree *) get_panel_widget (get_current_index ());
|
||||
selected_name = tree_selected_name (tree);
|
||||
tmp = g_strdup (vfs_path_as_str (selected_name));
|
||||
}
|
||||
else
|
||||
tmp = g_strdup (selection (current_panel)->fname);
|
||||
@ -922,22 +914,10 @@ done_mc (void)
|
||||
g_free (curr_dir);
|
||||
|
||||
if ((current_panel != NULL) && (get_current_type () == view_listing))
|
||||
{
|
||||
char *tmp_path;
|
||||
|
||||
tmp_path = vfs_path_to_str (current_panel->cwd_vpath);
|
||||
vfs_stamp_path (tmp_path);
|
||||
g_free (tmp_path);
|
||||
}
|
||||
vfs_stamp_path (vfs_path_as_str (current_panel->cwd_vpath));
|
||||
|
||||
if ((other_panel != NULL) && (get_other_type () == view_listing))
|
||||
{
|
||||
char *tmp_path;
|
||||
|
||||
tmp_path = vfs_path_to_str (other_panel->cwd_vpath);
|
||||
vfs_stamp_path (tmp_path);
|
||||
g_free (tmp_path);
|
||||
}
|
||||
vfs_stamp_path (vfs_path_as_str (other_panel->cwd_vpath));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1782,7 +1762,7 @@ do_nc (void)
|
||||
|
||||
/* destroy_dlg destroys even current_panel->cwd_vpath, so we have to save a copy :) */
|
||||
if (mc_args__last_wd_file != NULL && vfs_current_is_local ())
|
||||
last_wd_string = vfs_path_to_str (current_panel->cwd_vpath);
|
||||
last_wd_string = g_strdup (vfs_path_as_str (current_panel->cwd_vpath));
|
||||
|
||||
/* don't handle VFS timestamps for dirs opened in panels */
|
||||
mc_event_destroy (MCEVENT_GROUP_CORE, "vfs_timestamp");
|
||||
|
@ -2,12 +2,13 @@
|
||||
Panel managing.
|
||||
|
||||
Copyright (C) 1994, 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||
2005, 2006, 2007, 2009, 2011
|
||||
2005, 2006, 2007, 2009, 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Miguel de Icaza, 1995
|
||||
Timur Bakeyev, 1997, 1999
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -1116,28 +1117,24 @@ show_free_space (WPanel * panel)
|
||||
static struct my_statfs myfs_stats;
|
||||
/* Old current working directory for displaying free space */
|
||||
static char *old_cwd = NULL;
|
||||
char *tmp_path;
|
||||
|
||||
/* Don't try to stat non-local fs */
|
||||
if (!vfs_file_is_local (panel->cwd_vpath) || !free_space)
|
||||
return;
|
||||
|
||||
tmp_path = vfs_path_to_str (panel->cwd_vpath);
|
||||
if (old_cwd == NULL || strcmp (old_cwd, tmp_path) != 0)
|
||||
if (old_cwd == NULL || strcmp (old_cwd, vfs_path_as_str (panel->cwd_vpath)) != 0)
|
||||
{
|
||||
char rpath[PATH_MAX];
|
||||
|
||||
init_my_statfs ();
|
||||
g_free (old_cwd);
|
||||
old_cwd = tmp_path;
|
||||
tmp_path = NULL;
|
||||
old_cwd = g_strdup (vfs_path_as_str (panel->cwd_vpath));
|
||||
|
||||
if (mc_realpath (old_cwd, rpath) == NULL)
|
||||
return;
|
||||
|
||||
my_statfs (&myfs_stats, rpath);
|
||||
}
|
||||
g_free (tmp_path);
|
||||
|
||||
if (myfs_stats.avail != 0 || myfs_stats.total != 0)
|
||||
{
|
||||
@ -2162,13 +2159,9 @@ goto_parent_dir (WPanel * panel)
|
||||
if (g_path_is_absolute (fname))
|
||||
fname = g_strdup (fname);
|
||||
else
|
||||
{
|
||||
char *tmp_root;
|
||||
|
||||
tmp_root = vfs_path_to_str (panelized_panel.root_vpath);
|
||||
fname = mc_build_filename (tmp_root, fname, (char *) NULL);
|
||||
g_free (tmp_root);
|
||||
}
|
||||
fname =
|
||||
mc_build_filename (vfs_path_as_str (panelized_panel.root_vpath), fname,
|
||||
(char *) NULL);
|
||||
|
||||
bname = x_basename (fname);
|
||||
|
||||
@ -3038,10 +3031,7 @@ subshell_chdir (const vfs_path_t * vpath)
|
||||
static gboolean
|
||||
_do_panel_cd (WPanel * panel, const vfs_path_t * new_dir_vpath, enum cd_enum cd_type)
|
||||
{
|
||||
char *olddir;
|
||||
|
||||
olddir = vfs_path_to_str (panel->cwd_vpath);
|
||||
|
||||
vfs_path_t *olddir_vpath;
|
||||
/* Convert *new_path to a suitable pathname, handle ~user */
|
||||
if (cd_type == cd_parse_command)
|
||||
{
|
||||
@ -3054,43 +3044,39 @@ _do_panel_cd (WPanel * panel, const vfs_path_t * new_dir_vpath, enum cd_enum cd_
|
||||
|
||||
if (mc_chdir (new_dir_vpath) == -1)
|
||||
{
|
||||
panel_set_cwd (panel, olddir);
|
||||
g_free (olddir);
|
||||
panel_set_cwd (panel, vfs_path_as_str (panel->cwd_vpath));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Success: save previous directory, shutdown status of previous dir */
|
||||
panel_set_lwd (panel, olddir);
|
||||
olddir_vpath = vfs_path_clone (panel->cwd_vpath);
|
||||
panel_set_lwd (panel, vfs_path_as_str (panel->cwd_vpath));
|
||||
input_free_completions (cmdline);
|
||||
|
||||
vfs_path_free (panel->cwd_vpath);
|
||||
vfs_setup_cwd ();
|
||||
panel->cwd_vpath = vfs_path_clone (vfs_get_raw_current_dir ());
|
||||
|
||||
vfs_release_path (olddir);
|
||||
vfs_release_path (vfs_path_as_str (olddir_vpath));
|
||||
|
||||
subshell_chdir (panel->cwd_vpath);
|
||||
|
||||
/* Reload current panel */
|
||||
panel_clean_dir (panel);
|
||||
|
||||
{
|
||||
char *tmp_path;
|
||||
|
||||
panel->count =
|
||||
do_load_dir (panel->cwd_vpath, &panel->dir, panel->sort_info.sort_field->sort_routine,
|
||||
panel->sort_info.reverse, panel->sort_info.case_sensitive,
|
||||
panel->sort_info.exec_first, panel->filter);
|
||||
tmp_path = vfs_path_to_str (panel->cwd_vpath);
|
||||
try_to_select (panel, get_parent_dir_name (tmp_path, olddir));
|
||||
g_free (tmp_path);
|
||||
}
|
||||
panel->count =
|
||||
do_load_dir (panel->cwd_vpath, &panel->dir, panel->sort_info.sort_field->sort_routine,
|
||||
panel->sort_info.reverse, panel->sort_info.case_sensitive,
|
||||
panel->sort_info.exec_first, panel->filter);
|
||||
try_to_select (panel,
|
||||
get_parent_dir_name (vfs_path_as_str (panel->cwd_vpath),
|
||||
vfs_path_as_str (olddir_vpath)));
|
||||
|
||||
load_hint (0);
|
||||
panel->dirty = 1;
|
||||
update_xterm_title_path ();
|
||||
|
||||
g_free (olddir);
|
||||
vfs_path_free (olddir_vpath);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -4150,14 +4136,12 @@ void
|
||||
panel_reload (WPanel * panel)
|
||||
{
|
||||
struct stat current_stat;
|
||||
char *tmp_path;
|
||||
gboolean ok;
|
||||
|
||||
tmp_path = vfs_path_to_str (panel->cwd_vpath);
|
||||
ok = (panels_options.fast_reload && stat (tmp_path, ¤t_stat) == 0
|
||||
ok = (panels_options.fast_reload
|
||||
&& stat (vfs_path_as_str (panel->cwd_vpath), ¤t_stat) == 0
|
||||
&& current_stat.st_ctime == panel->dir_stat.st_ctime
|
||||
&& current_stat.st_mtime == panel->dir_stat.st_mtime);
|
||||
g_free (tmp_path);
|
||||
|
||||
if (ok)
|
||||
return;
|
||||
@ -4165,28 +4149,28 @@ panel_reload (WPanel * panel)
|
||||
do
|
||||
{
|
||||
char *last_slash;
|
||||
const char *panel_cwd_path;
|
||||
|
||||
if (mc_chdir (panel->cwd_vpath) != -1)
|
||||
break;
|
||||
|
||||
tmp_path = vfs_path_to_str (panel->cwd_vpath);
|
||||
if (tmp_path[0] == PATH_SEP && tmp_path[1] == '\0')
|
||||
panel_cwd_path = vfs_path_as_str (panel->cwd_vpath);
|
||||
|
||||
if (panel_cwd_path[0] == PATH_SEP && panel_cwd_path[1] == '\0')
|
||||
{
|
||||
panel_clean_dir (panel);
|
||||
panel->count = set_zero_dir (&panel->dir) ? 1 : 0;
|
||||
g_free (tmp_path);
|
||||
return;
|
||||
}
|
||||
last_slash = strrchr (tmp_path, PATH_SEP);
|
||||
last_slash = strrchr (panel_cwd_path, PATH_SEP);
|
||||
vfs_path_free (panel->cwd_vpath);
|
||||
if (last_slash == NULL || last_slash == tmp_path)
|
||||
if (last_slash == NULL || last_slash == panel_cwd_path)
|
||||
panel->cwd_vpath = vfs_path_from_str (PATH_SEP_STR);
|
||||
else
|
||||
{
|
||||
*last_slash = '\0';
|
||||
panel->cwd_vpath = vfs_path_from_str (tmp_path);
|
||||
panel->cwd_vpath = vfs_path_clone (panel->cwd_vpath);
|
||||
}
|
||||
g_free (tmp_path);
|
||||
memset (&(panel->dir_stat), 0, sizeof (panel->dir_stat));
|
||||
show_dir (panel);
|
||||
}
|
||||
@ -4538,13 +4522,10 @@ panel_change_encoding (WPanel * panel)
|
||||
encoding = get_codepage_id (panel->codepage);
|
||||
if (encoding != NULL)
|
||||
{
|
||||
char *cd_path;
|
||||
vfs_change_encoding (panel->cwd_vpath, encoding);
|
||||
|
||||
cd_path = vfs_path_to_str (panel->cwd_vpath);
|
||||
if (!do_panel_cd (panel, panel->cwd_vpath, cd_parse_command))
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot chdir to \"%s\""), cd_path);
|
||||
g_free (cd_path);
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot chdir to \"%s\""), panel->cwd_vpath->str);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -439,7 +439,7 @@ do_panelize_cd (struct WPanel *panel)
|
||||
tmp_vpath =
|
||||
vfs_path_append_new (panelized_panel.root_vpath, panelized_panel.list.list[i].fname,
|
||||
NULL);
|
||||
list->list[i].fname = vfs_path_to_str (tmp_vpath);
|
||||
list->list[i].fname = g_strdup (vfs_path_as_str (tmp_vpath));
|
||||
vfs_path_free (tmp_vpath);
|
||||
list->list[i].fnamelen = strlen (list->list[i].fname);
|
||||
}
|
||||
|
@ -7,13 +7,14 @@
|
||||
it will be possible to have tree views over virtual file systems.
|
||||
|
||||
Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
2003, 2004, 2005, 2007, 2011
|
||||
2003, 2004, 2005, 2007, 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Janne Kukonlehto, 1994, 1996
|
||||
Norbert Warmuth, 1997
|
||||
Miguel de Icaza, 1996, 1999
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -251,14 +252,11 @@ tree_show_mini_info (WTree * tree, int tree_lines, int tree_cols)
|
||||
{
|
||||
/* Show full name of selected directory */
|
||||
WDialog *h = w->owner;
|
||||
char *tmp_path;
|
||||
|
||||
tty_setcolor (tree->is_panel ? NORMAL_COLOR : TREE_NORMALC (h));
|
||||
tty_draw_hline (w->y + line, w->x + 1, ' ', tree_cols);
|
||||
widget_move (w, line, 1);
|
||||
tmp_path = vfs_path_to_str (tree->selected_ptr->name);
|
||||
tty_print_string (str_fit_to_term (tmp_path, tree_cols, J_LEFT_FIT));
|
||||
g_free (tmp_path);
|
||||
tty_print_string (str_fit_to_term (tree->selected_ptr->name->str, tree_cols, J_LEFT_FIT));
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,10 +305,8 @@ show_tree (WTree * tree)
|
||||
i = 0;
|
||||
while (current->prev && i < tree->topdiff)
|
||||
{
|
||||
char *current_name;
|
||||
|
||||
current = current->prev;
|
||||
current_name = vfs_path_to_str (current->name);
|
||||
|
||||
if (current->sublevel < tree->selected_ptr->sublevel)
|
||||
{
|
||||
@ -319,7 +315,7 @@ show_tree (WTree * tree)
|
||||
}
|
||||
else if (current->sublevel == tree->selected_ptr->sublevel)
|
||||
{
|
||||
for (j = strlen (current_name) - 1; current_name[j] != PATH_SEP; j--);
|
||||
for (j = strlen (current->name->str) - 1; current->name->str[j] != PATH_SEP; j--);
|
||||
if (vfs_path_equal_len (current->name, tree->selected_ptr->name, j))
|
||||
i++;
|
||||
}
|
||||
@ -333,7 +329,6 @@ show_tree (WTree * tree)
|
||||
i++;
|
||||
}
|
||||
}
|
||||
g_free (current_name);
|
||||
}
|
||||
tree->topdiff = i;
|
||||
}
|
||||
@ -357,15 +352,10 @@ show_tree (WTree * tree)
|
||||
|
||||
tree->tree_shown[i] = current;
|
||||
if (current->sublevel == topsublevel)
|
||||
{
|
||||
/* Show full name */
|
||||
char *current_name;
|
||||
|
||||
current_name = vfs_path_to_str (current->name);
|
||||
tty_print_string (str_fit_to_term
|
||||
(current_name, tree_cols + (tree->is_panel ? 0 : 1), J_LEFT_FIT));
|
||||
g_free (current_name);
|
||||
}
|
||||
(current->name->str, tree_cols + (tree->is_panel ? 0 : 1),
|
||||
J_LEFT_FIT));
|
||||
else
|
||||
{
|
||||
/* Sub level directory */
|
||||
@ -412,12 +402,9 @@ show_tree (WTree * tree)
|
||||
}
|
||||
else if (current->sublevel == tree->selected_ptr->sublevel)
|
||||
{
|
||||
char *current_name;
|
||||
|
||||
current_name = vfs_path_to_str (current->name);
|
||||
for (j = strlen (current_name) - 1; current_name[j] != PATH_SEP; j--)
|
||||
for (j = strlen (current->name->str) - 1; current->name->str[j] != PATH_SEP;
|
||||
j--)
|
||||
;
|
||||
g_free (current_name);
|
||||
if (vfs_path_equal_len (current->name, tree->selected_ptr->name, j))
|
||||
break;
|
||||
}
|
||||
@ -601,21 +588,17 @@ tree_mouse_click (WTree * tree, int y)
|
||||
static void
|
||||
tree_chdir_sel (WTree * tree)
|
||||
{
|
||||
char *tmp_path;
|
||||
|
||||
if (!tree->is_panel)
|
||||
return;
|
||||
|
||||
change_panel ();
|
||||
|
||||
tmp_path = vfs_path_to_str (tree->selected_ptr->name);
|
||||
if (do_cd (tree->selected_ptr->name, cd_exact))
|
||||
select_item (current_panel);
|
||||
else
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot chdir to \"%s\"\n%s"),
|
||||
tmp_path, unix_error_string (errno));
|
||||
tree->selected_ptr->name->str, unix_error_string (errno));
|
||||
|
||||
g_free (tmp_path);
|
||||
change_panel ();
|
||||
show_tree (tree);
|
||||
}
|
||||
@ -775,15 +758,13 @@ static void
|
||||
tree_copy (WTree * tree, const char *default_dest)
|
||||
{
|
||||
char msg[BUF_MEDIUM];
|
||||
char *dest, *selected_ptr_name;
|
||||
char *dest;
|
||||
|
||||
if (tree->selected_ptr == NULL)
|
||||
return;
|
||||
|
||||
selected_ptr_name = vfs_path_to_str (tree->selected_ptr->name);
|
||||
|
||||
g_snprintf (msg, sizeof (msg), _("Copy \"%s\" directory to:"),
|
||||
str_trunc (selected_ptr_name, 50));
|
||||
str_trunc (tree->selected_ptr->name->str, 50));
|
||||
dest = input_expand_dialog (Q_ ("DialogTitle|Copy"),
|
||||
msg, MC_HISTORY_FM_TREE_COPY, default_dest,
|
||||
INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_CD);
|
||||
@ -797,13 +778,12 @@ tree_copy (WTree * tree, const char *default_dest)
|
||||
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, selected_ptr_name, dest, TRUE, FALSE, FALSE, NULL);
|
||||
copy_dir_dir (tctx, ctx, tree->selected_ptr->name->str, dest, TRUE, FALSE, FALSE, NULL);
|
||||
file_op_total_context_destroy (tctx);
|
||||
file_op_context_destroy (ctx);
|
||||
}
|
||||
|
||||
g_free (dest);
|
||||
g_free (selected_ptr_name);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -812,7 +792,7 @@ static void
|
||||
tree_move (WTree * tree, const char *default_dest)
|
||||
{
|
||||
char msg[BUF_MEDIUM];
|
||||
char *dest, *selected_ptr_name;
|
||||
char *dest;
|
||||
struct stat buf;
|
||||
FileOpContext *ctx;
|
||||
FileOpTotalContext *tctx;
|
||||
@ -820,10 +800,8 @@ tree_move (WTree * tree, const char *default_dest)
|
||||
if (tree->selected_ptr == NULL)
|
||||
return;
|
||||
|
||||
selected_ptr_name = vfs_path_to_str (tree->selected_ptr->name);
|
||||
|
||||
g_snprintf (msg, sizeof (msg), _("Move \"%s\" directory to:"),
|
||||
str_trunc (selected_ptr_name, 50));
|
||||
str_trunc (tree->selected_ptr->name->str, 50));
|
||||
dest =
|
||||
input_expand_dialog (Q_ ("DialogTitle|Move"), msg, MC_HISTORY_FM_TREE_MOVE, default_dest,
|
||||
INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_CD);
|
||||
@ -847,12 +825,11 @@ tree_move (WTree * tree, const char *default_dest)
|
||||
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, selected_ptr_name, dest);
|
||||
move_dir_dir (tctx, ctx, tree->selected_ptr->name->str, dest);
|
||||
file_op_total_context_destroy (tctx);
|
||||
file_op_context_destroy (ctx);
|
||||
|
||||
ret:
|
||||
g_free (selected_ptr_name);
|
||||
g_free (dest);
|
||||
}
|
||||
|
||||
@ -892,11 +869,8 @@ tree_rmdir (void *data)
|
||||
{
|
||||
char *buf;
|
||||
int result;
|
||||
char *selected_ptr_name;
|
||||
|
||||
selected_ptr_name = vfs_path_to_str (tree->selected_ptr->name);
|
||||
buf = g_strdup_printf (_("Delete %s?"), selected_ptr_name);
|
||||
g_free (selected_ptr_name);
|
||||
buf = g_strdup_printf (_("Delete %s?"), tree->selected_ptr->name->str);
|
||||
|
||||
result = query_dialog (Q_ ("DialogTitle|Delete"), buf, D_ERROR, 2, _("&Yes"), _("&No"));
|
||||
g_free (buf);
|
||||
|
@ -9,13 +9,14 @@
|
||||
it will be possible to have tree views over virtual file systems.
|
||||
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2009,
|
||||
2011
|
||||
2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Janne Kukonlehto, 1994, 1996
|
||||
Norbert Warmuth, 1997
|
||||
Miguel de Icaza, 1996, 1999
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -98,18 +99,15 @@ static size_t
|
||||
str_common (const vfs_path_t * s1_vpath, const vfs_path_t * s2_vpath)
|
||||
{
|
||||
size_t result = 0;
|
||||
char *s1, *fs1;
|
||||
char *s2, *fs2;
|
||||
char *s1;
|
||||
char *s2;
|
||||
|
||||
s1 = fs1 = vfs_path_to_str (s1_vpath);
|
||||
s2 = fs2 = vfs_path_to_str (s2_vpath);
|
||||
s1 = vfs_path_as_str (s1_vpath);
|
||||
s2 = vfs_path_as_str (s2_vpath);
|
||||
|
||||
while (*s1 != '\0' && *s2 != '\0' && *s1++ == *s2++)
|
||||
result++;
|
||||
|
||||
g_free (fs1);
|
||||
g_free (fs2);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -140,19 +138,15 @@ static int
|
||||
pathcmp (const vfs_path_t * p1_vpath, const vfs_path_t * p2_vpath)
|
||||
{
|
||||
int ret_val;
|
||||
char *p1, *fp1;
|
||||
char *p2, *fp2;
|
||||
char *p1;
|
||||
char *p2;
|
||||
|
||||
p1 = fp1 = vfs_path_to_str (p1_vpath);
|
||||
p2 = fp2 = vfs_path_to_str (p2_vpath);
|
||||
p1 = vfs_path_as_str (p1_vpath);
|
||||
p2 = vfs_path_as_str (p2_vpath);
|
||||
|
||||
for (; *p1 == *p2; p1++, p2++)
|
||||
if (*p1 == '\0')
|
||||
{
|
||||
g_free (fp1);
|
||||
g_free (fp2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (*p1 == '\0')
|
||||
ret_val = -1;
|
||||
@ -165,8 +159,6 @@ pathcmp (const vfs_path_t * p1_vpath, const vfs_path_t * p2_vpath)
|
||||
else
|
||||
ret_val = (*p1 - *p2);
|
||||
|
||||
g_free (fp1);
|
||||
g_free (fp2);
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
@ -332,12 +324,7 @@ tree_store_load_from (char *name)
|
||||
static char *
|
||||
encode (const vfs_path_t * vpath, size_t offset)
|
||||
{
|
||||
char *string, *ret_val;
|
||||
|
||||
string = vfs_path_to_str (vpath);
|
||||
ret_val = strutils_escape (string + offset, -1, "\n\\", FALSE);
|
||||
g_free (string);
|
||||
return ret_val;
|
||||
return strutils_escape (vfs_path_as_str (vpath) + offset, -1, "\n\\", FALSE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -581,7 +568,6 @@ should_skip_directory (const vfs_path_t * vpath)
|
||||
static GList *special_dirs = NULL;
|
||||
GList *l;
|
||||
static gboolean loaded = FALSE;
|
||||
char *dir;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
if (!loaded)
|
||||
@ -592,15 +578,13 @@ should_skip_directory (const vfs_path_t * vpath)
|
||||
process_special_dirs (&special_dirs, global_profile_name);
|
||||
}
|
||||
|
||||
dir = vfs_path_to_str (vpath);
|
||||
for (l = special_dirs; l != NULL; l = g_list_next (l))
|
||||
if (strncmp (dir, l->data, strlen (l->data)) == 0)
|
||||
if (strncmp (vfs_path_as_str (vpath), l->data, strlen (l->data)) == 0)
|
||||
{
|
||||
ret = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (dir);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -710,12 +694,11 @@ tree_store_remove_entry (const vfs_path_t * name_vpath)
|
||||
|
||||
/* Miguel Ugly hack */
|
||||
{
|
||||
char *name;
|
||||
gboolean is_root;
|
||||
const char *name_vpath_str;
|
||||
|
||||
name = vfs_path_to_str (name_vpath);
|
||||
is_root = (name[0] == PATH_SEP && name[1] == '\0');
|
||||
g_free (name);
|
||||
name_vpath_str = vfs_path_as_str (name_vpath);
|
||||
is_root = (name_vpath_str[0] == PATH_SEP && name_vpath_str[1] == '\0');
|
||||
if (is_root)
|
||||
return;
|
||||
}
|
||||
@ -729,12 +712,9 @@ tree_store_remove_entry (const vfs_path_t * name_vpath)
|
||||
current = base->next;
|
||||
while (current != NULL && vfs_path_equal_len (current->name, base->name, len))
|
||||
{
|
||||
char *current_name;
|
||||
gboolean ok;
|
||||
|
||||
current_name = vfs_path_to_str (current->name);
|
||||
ok = (current_name[len] == '\0' || current_name[len] == PATH_SEP);
|
||||
g_free (current_name);
|
||||
ok = (current->name->str[len] == '\0' || current->name->str[len] == PATH_SEP);
|
||||
if (!ok)
|
||||
break;
|
||||
old = current;
|
||||
@ -752,7 +732,6 @@ void
|
||||
tree_store_mark_checked (const char *subname)
|
||||
{
|
||||
vfs_path_t *name;
|
||||
char *check_name;
|
||||
tree_entry *current, *base;
|
||||
int flag = 1;
|
||||
if (!ts.loaded)
|
||||
@ -765,12 +744,10 @@ tree_store_mark_checked (const char *subname)
|
||||
if (subname[0] == '.' && (subname[1] == 0 || (subname[1] == '.' && subname[2] == 0)))
|
||||
return;
|
||||
|
||||
check_name = vfs_path_to_str (ts.check_name);
|
||||
if (check_name[0] == PATH_SEP && check_name[1] == 0)
|
||||
if (ts.check_name->str[0] == PATH_SEP && ts.check_name->str[1] == 0)
|
||||
name = vfs_path_build_filename (PATH_SEP_STR, subname, NULL);
|
||||
else
|
||||
name = vfs_path_append_new (ts.check_name, subname, NULL);
|
||||
g_free (check_name);
|
||||
|
||||
/* Search for the subdirectory */
|
||||
current = ts.check_start;
|
||||
@ -798,9 +775,8 @@ tree_store_mark_checked (const char *subname)
|
||||
{
|
||||
gboolean ok;
|
||||
|
||||
check_name = vfs_path_to_str (current->name);
|
||||
ok = (check_name[len] == '\0' || check_name[len] == PATH_SEP || len == 1);
|
||||
g_free (check_name);
|
||||
ok = (current->name->str[len] == '\0' || current->name->str[len] == PATH_SEP
|
||||
|| len == 1);
|
||||
if (!ok)
|
||||
break;
|
||||
current->mark = 0;
|
||||
@ -853,12 +829,9 @@ tree_store_start_check (const vfs_path_t * vpath)
|
||||
current = ts.check_start;
|
||||
while (current != NULL && vfs_path_equal_len (current->name, ts.check_name, len))
|
||||
{
|
||||
char *current_name;
|
||||
gboolean ok;
|
||||
|
||||
current_name = vfs_path_to_str (current->name);
|
||||
ok = (current_name[len] == '\0' || current_name[len] == PATH_SEP || len == 1);
|
||||
g_free (current_name);
|
||||
ok = (current->name->str[len] == '\0' || current->name->str[len] == PATH_SEP || len == 1);
|
||||
if (!ok)
|
||||
break;
|
||||
current->mark = 1;
|
||||
@ -889,12 +862,9 @@ tree_store_end_check (void)
|
||||
current = ts.check_start;
|
||||
while (current != NULL && vfs_path_equal_len (current->name, ts.check_name, len))
|
||||
{
|
||||
char *current_name;
|
||||
gboolean ok;
|
||||
|
||||
current_name = vfs_path_to_str (current->name);
|
||||
ok = (current_name[len] == '\0' || current_name[len] == PATH_SEP || len == 1);
|
||||
g_free (current_name);
|
||||
ok = (current->name->str[len] == '\0' || current->name->str[len] == PATH_SEP || len == 1);
|
||||
|
||||
if (!ok)
|
||||
break;
|
||||
|
@ -2,9 +2,12 @@
|
||||
User Menu implementation
|
||||
|
||||
Copyright (C) 1994, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||
2006, 2007, 2011
|
||||
2006, 2007, 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander is free software: you can redistribute it
|
||||
@ -266,13 +269,8 @@ test_condition (WEdit * edit_widget, char *p, int *condition)
|
||||
break;
|
||||
case 'd':
|
||||
p = extract_arg (p, arg, sizeof (arg));
|
||||
{
|
||||
char *cwd_str;
|
||||
|
||||
cwd_str = vfs_path_to_str (panel->cwd_vpath);
|
||||
*condition = panel != NULL && mc_search (arg, cwd_str, search_type) ? 1 : 0;
|
||||
g_free (cwd_str);
|
||||
}
|
||||
*condition = panel != NULL
|
||||
&& mc_search (arg, vfs_path_as_str (panel->cwd_vpath), search_type) ? 1 : 0;
|
||||
break;
|
||||
case 't':
|
||||
p = extract_arg (p, arg, sizeof (arg));
|
||||
@ -547,22 +545,16 @@ execute_menu_command (WEdit * edit_widget, const char *commands, gboolean show_p
|
||||
mc_chmod (file_name_vpath, S_IRWXU);
|
||||
if (run_view)
|
||||
{
|
||||
char *file_name;
|
||||
|
||||
file_name = vfs_path_to_str (file_name_vpath);
|
||||
mcview_viewer (file_name, NULL, 0);
|
||||
g_free (file_name);
|
||||
mcview_viewer (vfs_path_as_str (file_name_vpath), NULL, 0);
|
||||
dialog_switch_process_pending ();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* execute the command indirectly to allow execution even
|
||||
* on no-exec filesystems. */
|
||||
char *file_name, *cmd;
|
||||
char *cmd;
|
||||
|
||||
file_name = vfs_path_to_str (file_name_vpath);
|
||||
cmd = g_strconcat ("/bin/sh ", file_name, (char *) NULL);
|
||||
g_free (file_name);
|
||||
cmd = g_strconcat ("/bin/sh ", vfs_path_as_str (file_name_vpath), (char *) NULL);
|
||||
if (!show_prompt)
|
||||
{
|
||||
if (system (cmd) == -1)
|
||||
@ -798,7 +790,7 @@ expand_format (struct WEdit *edit_widget, char c, gboolean do_quote)
|
||||
char *qstr;
|
||||
|
||||
if (panel)
|
||||
cwd = vfs_path_to_str (panel->cwd_vpath);
|
||||
cwd = g_strdup (vfs_path_as_str (panel->cwd_vpath));
|
||||
else
|
||||
cwd = vfs_get_current_dir ();
|
||||
|
||||
|
@ -2,9 +2,12 @@
|
||||
Concurrent shell support for the Midnight Commander
|
||||
|
||||
Copyright (C) 1994, 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||
2005, 2006, 2007, 2011
|
||||
2005, 2006, 2007, 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander is free software: you can redistribute it
|
||||
@ -958,13 +961,7 @@ invoke_subshell (const char *command, int how, vfs_path_t ** new_dir_vpath)
|
||||
|
||||
feed_subshell (how, FALSE);
|
||||
|
||||
{
|
||||
char *cwd_str;
|
||||
|
||||
cwd_str = vfs_path_to_str (current_panel->cwd_vpath);
|
||||
pcwd = vfs_translate_path_n (cwd_str);
|
||||
g_free (cwd_str);
|
||||
}
|
||||
pcwd = vfs_translate_path_n (vfs_path_as_str (current_panel->cwd_vpath));
|
||||
|
||||
if (new_dir_vpath != NULL && subshell_alive && strcmp (subshell_cwd, pcwd))
|
||||
*new_dir_vpath = vfs_path_from_str (subshell_cwd); /* Make MC change to the subshell's CWD */
|
||||
@ -1152,7 +1149,6 @@ void
|
||||
do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt, gboolean reset_prompt)
|
||||
{
|
||||
char *pcwd;
|
||||
char *directory;
|
||||
|
||||
pcwd = vfs_path_to_str_flags (current_panel->cwd_vpath, 0, VPF_RECODE);
|
||||
|
||||
@ -1172,12 +1168,11 @@ do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt, gboolean re
|
||||
because we set "HISTCONTROL=ignorespace") */
|
||||
write_all (mc_global.tty.subshell_pty, " cd ", 4);
|
||||
|
||||
directory = vfs_path_to_str (vpath);
|
||||
if (directory != NULL)
|
||||
if (vpath != NULL)
|
||||
{
|
||||
char *translate;
|
||||
|
||||
translate = vfs_translate_path_n (directory);
|
||||
translate = vfs_translate_path_n (vfs_path_as_str (vpath));
|
||||
if (translate != NULL)
|
||||
{
|
||||
GString *temp;
|
||||
@ -1197,7 +1192,6 @@ do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt, gboolean re
|
||||
{
|
||||
write_all (mc_global.tty.subshell_pty, "/", 1);
|
||||
}
|
||||
g_free (directory);
|
||||
write_all (mc_global.tty.subshell_pty, "\n", 1);
|
||||
|
||||
subshell_state = RUNNING_COMMAND;
|
||||
|
23
src/util.c
23
src/util.c
@ -1,11 +1,12 @@
|
||||
/*
|
||||
Various non-library utilities
|
||||
|
||||
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2011
|
||||
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Adam Byrtek, 2003
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -51,35 +52,23 @@
|
||||
gboolean
|
||||
check_for_default (const vfs_path_t * default_file_vpath, const vfs_path_t * file_vpath)
|
||||
{
|
||||
char *file;
|
||||
|
||||
file = vfs_path_to_str (file_vpath);
|
||||
|
||||
if (!exist_file (file))
|
||||
if (!exist_file (vfs_path_as_str (file_vpath)))
|
||||
{
|
||||
char *default_file;
|
||||
FileOpContext *ctx;
|
||||
FileOpTotalContext *tctx;
|
||||
|
||||
default_file = vfs_path_to_str (default_file_vpath);
|
||||
if (!exist_file (default_file))
|
||||
{
|
||||
g_free (file);
|
||||
g_free (default_file);
|
||||
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, default_file, file);
|
||||
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);
|
||||
g_free (default_file);
|
||||
}
|
||||
|
||||
g_free (file);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
/*
|
||||
Virtual File System: GNU Tar file system.
|
||||
|
||||
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2011
|
||||
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Jan Hudec, 2000
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -224,15 +225,11 @@ cpio_open_cpio_file (struct vfs_class *me, struct vfs_s_super *super, const vfs_
|
||||
fd = mc_open (vpath, O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
char *name;
|
||||
|
||||
name = vfs_path_to_str (vpath);
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), name);
|
||||
g_free (name);
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), vfs_path_as_str (vpath));
|
||||
return -1;
|
||||
}
|
||||
|
||||
super->name = vfs_path_to_str (vpath);
|
||||
super->name = g_strdup (vfs_path_as_str (vpath));
|
||||
super->data = g_new (cpio_super_data_t, 1);
|
||||
arch = (cpio_super_data_t *) super->data;
|
||||
arch->fd = -1; /* for now */
|
||||
@ -745,11 +742,8 @@ cpio_open_archive (struct vfs_s_super *super, const vfs_path_t * vpath,
|
||||
{
|
||||
case STATUS_EOF:
|
||||
{
|
||||
char *archive_name;
|
||||
|
||||
archive_name = vfs_path_to_str (vpath);
|
||||
message (D_ERROR, MSG_ERROR, _("Unexpected end of file\n%s"), archive_name);
|
||||
g_free (archive_name);
|
||||
message (D_ERROR, MSG_ERROR, _("Unexpected end of file\n%s"),
|
||||
vfs_path_as_str (vpath));
|
||||
return 0;
|
||||
}
|
||||
case STATUS_OK:
|
||||
@ -783,16 +777,11 @@ cpio_super_same (const vfs_path_element_t * vpath_element, struct vfs_s_super *p
|
||||
const vfs_path_t * vpath, void *cookie)
|
||||
{
|
||||
struct stat *archive_stat = cookie; /* stat of main archive */
|
||||
char *archive_name = vfs_path_to_str (vpath);
|
||||
|
||||
(void) vpath_element;
|
||||
|
||||
if (strcmp (parc->name, archive_name))
|
||||
{
|
||||
g_free (archive_name);
|
||||
if (strcmp (parc->name, vfs_path_as_str (vpath)))
|
||||
return 0;
|
||||
}
|
||||
g_free (archive_name);
|
||||
|
||||
/* Has the cached archive been changed on the disk? */
|
||||
if (((cpio_super_data_t *) parc->data)->st.st_mtime < archive_stat->st_mtime)
|
||||
|
@ -2,13 +2,14 @@
|
||||
Virtual File System: External file system.
|
||||
|
||||
Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||
2006, 2007, 2009, 2011
|
||||
2006, 2007, 2009, 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Jakub Jelinek, 1995
|
||||
Pavel Machek, 1998
|
||||
Andrew T. Veliath, 1999
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -665,7 +666,6 @@ extfs_which (struct vfs_class *me, const char *path)
|
||||
static const char *
|
||||
extfs_get_path_int (const vfs_path_t * vpath, struct archive **archive, gboolean do_not_open)
|
||||
{
|
||||
char *archive_name;
|
||||
int result = -1;
|
||||
struct archive *parc;
|
||||
int fstype;
|
||||
@ -677,8 +677,6 @@ extfs_get_path_int (const vfs_path_t * vpath, struct archive **archive, gboolean
|
||||
if (fstype == -1)
|
||||
return NULL;
|
||||
|
||||
archive_name = vfs_path_to_str_elements_count (vpath, -1);
|
||||
|
||||
/*
|
||||
* All filesystems should have some local archive, at least
|
||||
* it can be PATH_SEP ('/').
|
||||
@ -686,24 +684,22 @@ extfs_get_path_int (const vfs_path_t * vpath, struct archive **archive, gboolean
|
||||
for (parc = first_archive; parc != NULL; parc = parc->next)
|
||||
if (parc->name != NULL)
|
||||
{
|
||||
if (strcmp (parc->name, archive_name) == 0)
|
||||
if (strcmp (parc->name, vfs_path_as_str (vpath)) == 0)
|
||||
{
|
||||
vfs_stamp (&vfs_extfs_ops, (vfsid) parc);
|
||||
goto return_success;
|
||||
}
|
||||
}
|
||||
|
||||
result = do_not_open ? -1 : extfs_read_archive (fstype, archive_name, &parc);
|
||||
result = do_not_open ? -1 : extfs_read_archive (fstype, vfs_path_as_str (vpath), &parc);
|
||||
if (result == -1)
|
||||
{
|
||||
path_element->class->verrno = EIO;
|
||||
g_free (archive_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return_success:
|
||||
*archive = parc;
|
||||
g_free (archive_name);
|
||||
return path_element->path;
|
||||
}
|
||||
|
||||
|
@ -3,14 +3,14 @@
|
||||
shell connections.
|
||||
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
|
||||
2007, 2008, 2009, 2010, 2011
|
||||
2007, 2008, 2009, 2010, 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Pavel Machek, 1998
|
||||
Michal Svec, 2000
|
||||
Andrew Borodin <aborodin@vmail.ru>, 2010
|
||||
Slava Zanko <slavazanko@gmail.com>, 2010
|
||||
Slava Zanko <slavazanko@gmail.com>, 2010, 2013
|
||||
Ilia Maslakov <il.smind@gmail.com>, 2010
|
||||
|
||||
Derived from ftpfs.c.
|
||||
@ -1521,7 +1521,7 @@ fish_fh_open (struct vfs_class *me, vfs_file_handler_t * fh, int flags, mode_t m
|
||||
vfs_path_free (vpath);
|
||||
goto fail;
|
||||
}
|
||||
fh->ino->localname = vfs_path_to_str (vpath);
|
||||
fh->ino->localname = g_strdup (vfs_path_as_str (vpath));
|
||||
vfs_path_free (vpath);
|
||||
close (tmp_handle);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
Virtual File System: FTP file system.
|
||||
|
||||
Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||
2006, 2007, 2008, 2009, 2010, 2011
|
||||
2006, 2007, 2008, 2009, 2010, 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
@ -12,7 +12,7 @@
|
||||
Norbert Warmuth, 1997
|
||||
Pavel Machek, 1998
|
||||
Yury V. Zaytsev, 2010
|
||||
Slava Zanko <slavazanko@gmail.com>, 2010
|
||||
Slava Zanko <slavazanko@gmail.com>, 2010, 2013
|
||||
Andrew Borodin <aborodin@vmail.ru>, 2010
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
@ -2156,7 +2156,7 @@ ftpfs_fh_open (struct vfs_class *me, vfs_file_handler_t * fh, int flags, mode_t
|
||||
goto fail;
|
||||
}
|
||||
close (handle);
|
||||
fh->ino->localname = vfs_path_to_str (vpath);
|
||||
fh->ino->localname = g_strdup (vfs_path_as_str (vpath));
|
||||
vfs_path_free (vpath);
|
||||
ftp->append = flags & O_APPEND;
|
||||
}
|
||||
|
@ -2,9 +2,12 @@
|
||||
Single File fileSystem
|
||||
|
||||
Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
|
||||
2011
|
||||
2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander is free software: you can redistribute it
|
||||
@ -157,13 +160,8 @@ sfs_vfmake (const vfs_path_t * vpath, vfs_path_t * cache_vpath)
|
||||
vfs_path_free (s);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *pname_str;
|
||||
pqname = name_quote (vfs_path_as_str (pname), 0);
|
||||
|
||||
pname_str = vfs_path_to_str (pname);
|
||||
pqname = name_quote (pname_str, 0);
|
||||
g_free (pname_str);
|
||||
}
|
||||
vfs_path_free (pname);
|
||||
|
||||
|
||||
@ -226,12 +224,9 @@ sfs_redirect (const vfs_path_t * vpath)
|
||||
vfs_path_t *cache_vpath;
|
||||
int handle;
|
||||
const vfs_path_element_t *path_element;
|
||||
char *path;
|
||||
|
||||
path = vfs_path_to_str (vpath);
|
||||
path_element = vfs_path_get_by_index (vpath, -1);
|
||||
cur = g_slist_find_custom (head, path, cachedfile_compare);
|
||||
g_free (path);
|
||||
cur = g_slist_find_custom (head, vfs_path_as_str (vpath), cachedfile_compare);
|
||||
|
||||
if (cur != NULL)
|
||||
{
|
||||
@ -250,8 +245,8 @@ sfs_redirect (const vfs_path_t * vpath)
|
||||
if (sfs_vfmake (vpath, cache_vpath) == 0)
|
||||
{
|
||||
cf = g_new (cachedfile, 1);
|
||||
cf->name = vfs_path_to_str (vpath);
|
||||
cf->cache = vfs_path_to_str (cache_vpath);
|
||||
cf->name = g_strdup (vfs_path_as_str (vpath));
|
||||
cf->cache = g_strdup (vfs_path_as_str (cache_vpath));
|
||||
head = g_slist_prepend (head, cf);
|
||||
vfs_path_free (cache_vpath);
|
||||
|
||||
@ -341,10 +336,8 @@ static vfsid
|
||||
sfs_getid (const vfs_path_t * vpath)
|
||||
{
|
||||
GSList *cur;
|
||||
char *path = vfs_path_to_str (vpath);
|
||||
|
||||
cur = g_slist_find_custom (head, path, cachedfile_compare);
|
||||
g_free (path);
|
||||
cur = g_slist_find_custom (head, vfs_path_as_str (vpath), cachedfile_compare);
|
||||
|
||||
return (vfsid) (cur != NULL ? cur->data : NULL);
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* Virtual File System: SFTP file system.
|
||||
The SSH config parser
|
||||
|
||||
Copyright (C) 2011
|
||||
Copyright (C) 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Ilia Maslakov <il.smind@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2012
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011, 2012, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -121,7 +121,7 @@ sftpfs_correct_file_name (const char *filename)
|
||||
char *ret_value;
|
||||
|
||||
vpath = vfs_path_from_str (filename);
|
||||
ret_value = vfs_path_to_str (vpath);
|
||||
ret_value = g_strdup (vfs_path_as_str (vpath));
|
||||
vfs_path_free (vpath);
|
||||
return ret_value;
|
||||
}
|
||||
|
@ -2,12 +2,13 @@
|
||||
Virtual File System: GNU Tar file system.
|
||||
|
||||
Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||
2006, 2007, 2011
|
||||
2006, 2007, 2011, 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Jakub Jelinek, 1995
|
||||
Pavel Machek, 1998
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -291,15 +292,11 @@ tar_open_archive_int (struct vfs_class *me, const vfs_path_t * vpath, struct vfs
|
||||
result = mc_open (vpath, O_RDONLY);
|
||||
if (result == -1)
|
||||
{
|
||||
char *name;
|
||||
|
||||
name = vfs_path_to_str (vpath);
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot open tar archive\n%s"), name);
|
||||
g_free (name);
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot open tar archive\n%s"), vfs_path_as_str (vpath));
|
||||
ERRNOR (ENOENT, -1);
|
||||
}
|
||||
|
||||
archive->name = vfs_path_to_str (vpath);
|
||||
archive->name = g_strdup (vfs_path_as_str (vpath));
|
||||
archive->data = g_new (tar_super_data_t, 1);
|
||||
arch = (tar_super_data_t *) archive->data;
|
||||
mc_stat (vpath, &arch->st);
|
||||
@ -791,10 +788,8 @@ tar_open_archive (struct vfs_s_super *archive, const vfs_path_t * vpath,
|
||||
/* Error on first record */
|
||||
case STATUS_EOFMARK:
|
||||
{
|
||||
char *archive_name = vfs_path_to_str (vpath);
|
||||
message (D_ERROR, MSG_ERROR, _("%s\ndoesn't look like a tar archive."),
|
||||
archive_name);
|
||||
g_free (archive_name);
|
||||
vfs_path_as_str (vpath));
|
||||
/* FALL THRU */
|
||||
|
||||
/* Error after header rec */
|
||||
@ -841,16 +836,11 @@ tar_super_same (const vfs_path_element_t * vpath_element, struct vfs_s_super *pa
|
||||
const vfs_path_t * vpath, void *cookie)
|
||||
{
|
||||
struct stat *archive_stat = cookie; /* stat of main archive */
|
||||
char *archive_name = vfs_path_to_str (vpath);
|
||||
|
||||
(void) vpath_element;
|
||||
|
||||
if (strcmp (parc->name, archive_name) != 0)
|
||||
{
|
||||
g_free (archive_name);
|
||||
if (strcmp (parc->name, vfs_path_as_str (vpath)) != 0)
|
||||
return 0;
|
||||
}
|
||||
g_free (archive_name);
|
||||
|
||||
/* Has the cached archive been changed on the disk? */
|
||||
if (((tar_super_data_t *) parc->data)->st.st_mtime < archive_stat->st_mtime)
|
||||
|
@ -14,7 +14,7 @@
|
||||
Norbert Warmuth, 1997
|
||||
Pavel Machek, 1998
|
||||
Roland Illig <roland.illig@gmx.de>, 2004, 2005
|
||||
Slava Zanko <slavazanko@google.com>, 2009
|
||||
Slava Zanko <slavazanko@google.com>, 2009, 2013
|
||||
Andrew Borodin <aborodin@vmail.ru>, 2009, 2013
|
||||
Ilia Maslakov <il.smind@gmail.com>, 2009
|
||||
|
||||
@ -275,7 +275,6 @@ mcview_load_next_prev_init (mcview_t * view)
|
||||
|
||||
/* TODO: check mtime of directory to reload it */
|
||||
|
||||
char *full_fname;
|
||||
const char *fname;
|
||||
size_t fname_len;
|
||||
int i;
|
||||
@ -288,8 +287,7 @@ mcview_load_next_prev_init (mcview_t * view)
|
||||
*view->dir_count = do_load_dir (view->workdir_vpath, view->dir, (sortfn *) sort_name, FALSE,
|
||||
TRUE, FALSE, NULL);
|
||||
|
||||
full_fname = vfs_path_to_str (view->filename_vpath);
|
||||
fname = x_basename (full_fname);
|
||||
fname = x_basename (vfs_path_as_str (view->filename_vpath));
|
||||
fname_len = strlen (fname);
|
||||
|
||||
/* search current file in the list */
|
||||
@ -301,8 +299,6 @@ mcview_load_next_prev_init (mcview_t * view)
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (full_fname);
|
||||
|
||||
*view->dir_idx = i;
|
||||
}
|
||||
}
|
||||
@ -352,13 +348,7 @@ mcview_load_next_prev (mcview_t * view, int direction)
|
||||
mcview_remove_ext_script (view);
|
||||
mcview_init (view);
|
||||
if (regex_command_for (view, vfile, "View", &ext_script) == 0)
|
||||
{
|
||||
char *file;
|
||||
|
||||
file = vfs_path_to_str (vfile);
|
||||
mcview_load (view, NULL, file, 0);
|
||||
g_free (file);
|
||||
}
|
||||
mcview_load (view, NULL, vfs_path_as_str (vfile), 0);
|
||||
vfs_path_free (vfile);
|
||||
view->dir = dir;
|
||||
view->dir_count = dir_count;
|
||||
|
@ -14,7 +14,7 @@
|
||||
Norbert Warmuth, 1997
|
||||
Pavel Machek, 1998
|
||||
Roland Illig <roland.illig@gmx.de>, 2004, 2005
|
||||
Slava Zanko <slavazanko@google.com>, 2009
|
||||
Slava Zanko <slavazanko@google.com>, 2009, 2013
|
||||
Andrew Borodin <aborodin@vmail.ru>, 2009, 2013
|
||||
Ilia Maslakov <il.smind@gmail.com>, 2009
|
||||
|
||||
@ -76,7 +76,7 @@ const off_t OFFSETTYPE_MAX = ((off_t) 1 << (OFF_T_BITWIDTH - 1)) - 1;
|
||||
void
|
||||
mcview_toggle_magic_mode (mcview_t * view)
|
||||
{
|
||||
char *filename, *command;
|
||||
char *command;
|
||||
dir_list *dir;
|
||||
int *dir_count, *dir_idx;
|
||||
|
||||
@ -84,7 +84,6 @@ mcview_toggle_magic_mode (mcview_t * view)
|
||||
view->magic_mode = !view->magic_mode;
|
||||
|
||||
/* reinit view */
|
||||
filename = vfs_path_to_str (view->filename_vpath);
|
||||
command = g_strdup (view->command);
|
||||
dir = view->dir;
|
||||
dir_count = view->dir_count;
|
||||
@ -94,11 +93,10 @@ mcview_toggle_magic_mode (mcview_t * view)
|
||||
view->dir_idx = NULL;
|
||||
mcview_done (view);
|
||||
mcview_init (view);
|
||||
mcview_load (view, command, filename, 0);
|
||||
mcview_load (view, command, vfs_path_as_str (view->filename_vpath), 0);
|
||||
view->dir = dir;
|
||||
view->dir_count = dir_count;
|
||||
view->dir_idx = dir_idx;
|
||||
g_free (filename);
|
||||
g_free (command);
|
||||
|
||||
view->dpy_bbar_dirty = TRUE;
|
||||
@ -437,10 +435,10 @@ mcview_get_title (const WDialog * h, size_t len)
|
||||
const mcview_t *view = (const mcview_t *) find_widget_type (h, mcview_callback);
|
||||
const char *modified = view->hexedit_mode && (view->change_list != NULL) ? "(*) " : " ";
|
||||
const char *file_label;
|
||||
char *view_filename;
|
||||
const char *view_filename;
|
||||
char *ret_str;
|
||||
|
||||
view_filename = view->filename_vpath != NULL ? vfs_path_to_str (view->filename_vpath) : NULL;
|
||||
view_filename = vfs_path_as_str (view->filename_vpath);
|
||||
|
||||
len -= 4;
|
||||
|
||||
@ -448,7 +446,6 @@ mcview_get_title (const WDialog * h, size_t len)
|
||||
file_label = str_term_trim (file_label, len - str_term_width1 (_("View: ")));
|
||||
|
||||
ret_str = g_strconcat (_("View: "), modified, file_label, (char *) NULL);
|
||||
g_free (view_filename);
|
||||
return ret_str;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
Norbert Warmuth, 1997
|
||||
Pavel Machek, 1998
|
||||
Roland Illig <roland.illig@gmx.de>, 2004, 2005
|
||||
Slava Zanko <slavazanko@google.com>, 2009
|
||||
Slava Zanko <slavazanko@google.com>, 2009, 2013
|
||||
Andrew Borodin <aborodin@vmail.ru>, 2009, 2013
|
||||
Ilia Maslakov <il.smind@gmail.com>, 2009
|
||||
|
||||
@ -246,13 +246,7 @@ mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_lin
|
||||
|
||||
view_dlg->get_title = mcview_get_title;
|
||||
|
||||
{
|
||||
char *file;
|
||||
|
||||
file = vfs_path_to_str (file_vpath);
|
||||
succeeded = mcview_load (lc_mcview, command, file, start_line);
|
||||
g_free (file);
|
||||
}
|
||||
succeeded = mcview_load (lc_mcview, command, vfs_path_as_str (file_vpath), start_line);
|
||||
|
||||
if (succeeded)
|
||||
run_dlg (view_dlg);
|
||||
|
@ -354,13 +354,8 @@ START_PARAMETRIZED_TEST (test_vfs_path_append_vpath, test_vfs_path_append_vpath_
|
||||
vpath3 = vfs_path_append_vpath_new (vpath1, vpath2, NULL);
|
||||
|
||||
/* then */
|
||||
{
|
||||
char *path;
|
||||
mctest_assert_int_eq (vfs_path_elements_count (vpath3), data->expected_element_count);
|
||||
path = vfs_path_to_str (vpath3);
|
||||
mctest_assert_str_eq (path, data->expected_path);
|
||||
g_free (path);
|
||||
}
|
||||
mctest_assert_int_eq (vfs_path_elements_count (vpath3), data->expected_element_count);
|
||||
mctest_assert_str_eq (vfs_path_as_str (vpath3), data->expected_path);
|
||||
|
||||
vfs_path_free (vpath1);
|
||||
vfs_path_free (vpath2);
|
||||
@ -409,14 +404,8 @@ START_PARAMETRIZED_TEST (test_vfs_path_relative, test_vfs_path_relative_ds)
|
||||
/* then */
|
||||
mctest_assert_int_eq (vpath->relative, TRUE);
|
||||
mctest_assert_str_eq (vfs_path_get_last_path_str (vpath), data->expected_last_path_in_element);
|
||||
mctest_assert_str_eq (vfs_path_as_str (vpath), data->expected_path);
|
||||
|
||||
{
|
||||
char *path_str;
|
||||
|
||||
path_str = vfs_path_to_str (vpath);
|
||||
mctest_assert_str_eq (path_str, data->expected_path);
|
||||
g_free (path_str);
|
||||
}
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
@ -443,14 +432,8 @@ START_PARAMETRIZED_TEST (test_vfs_path_relative_clone, test_vfs_path_relative_ds
|
||||
mctest_assert_int_eq (cloned_vpath->relative, TRUE);
|
||||
mctest_assert_str_eq (vfs_path_get_last_path_str (cloned_vpath),
|
||||
data->expected_last_path_in_element);
|
||||
mctest_assert_str_eq (vfs_path_as_str (cloned_vpath), data->expected_path);
|
||||
|
||||
{
|
||||
char *path_str;
|
||||
|
||||
path_str = vfs_path_to_str (cloned_vpath);
|
||||
mctest_assert_str_eq (path_str, data->expected_path);
|
||||
g_free (path_str);
|
||||
}
|
||||
vfs_path_free (vpath);
|
||||
vfs_path_free (cloned_vpath);
|
||||
}
|
||||
|
@ -141,21 +141,21 @@ START_PARAMETRIZED_TEST (test_path_recode, test_path_recode_ds)
|
||||
{
|
||||
/* given */
|
||||
vfs_path_t *vpath;
|
||||
char *result;
|
||||
const vfs_path_element_t *element;
|
||||
const char *vpath_str;
|
||||
|
||||
test_init_vfs (data->input_codepage);
|
||||
|
||||
/* when */
|
||||
vpath = vfs_path_from_str (data->input_path);
|
||||
element = vfs_path_get_by_index (vpath, -1);
|
||||
result = vfs_path_to_str (vpath);
|
||||
|
||||
/* then */
|
||||
vpath_str = vfs_path_as_str (vpath);
|
||||
mctest_assert_ptr_ne (vpath, NULL);
|
||||
mctest_assert_str_eq (element->path, data->expected_element_path);
|
||||
mctest_assert_str_eq (result, data->expected_recoded_path);
|
||||
mctest_assert_str_eq (vpath_str, data->expected_recoded_path);
|
||||
|
||||
g_free (result);
|
||||
vfs_path_free (vpath);
|
||||
test_deinit_vfs ();
|
||||
}
|
||||
|
@ -173,19 +173,16 @@ START_TEST (test_path_deserialize)
|
||||
{
|
||||
/* given */
|
||||
vfs_path_t *vpath;
|
||||
char *path;
|
||||
GError *error = NULL;
|
||||
|
||||
/* when */
|
||||
vpath = vfs_path_deserialize (ETALON_SERIALIZED_PATH, &error);
|
||||
path = vfs_path_to_str (vpath);
|
||||
|
||||
/* then */
|
||||
mctest_assert_ptr_ne (vpath, NULL);
|
||||
mctest_assert_str_eq (path, ETALON_PATH_URL_STR);
|
||||
mctest_assert_str_eq (vfs_path_as_str (vpath), ETALON_PATH_URL_STR);
|
||||
|
||||
vfs_path_free (vpath);
|
||||
g_free (path);
|
||||
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
|
@ -99,26 +99,24 @@ START_TEST (test_mc_mkstemps)
|
||||
{
|
||||
/* given */
|
||||
vfs_path_t *pname_vpath = NULL;
|
||||
char *pname = NULL;
|
||||
char *begin_pname;
|
||||
int fd;
|
||||
|
||||
/* when */
|
||||
fd = mc_mkstemps (&pname_vpath, "mctest-", NULL);
|
||||
if (fd != -1)
|
||||
pname = vfs_path_to_str (pname_vpath);
|
||||
begin_pname = g_build_filename (mc_tmpdir (), "mctest-", NULL);
|
||||
|
||||
/* then */
|
||||
vfs_path_free (pname_vpath);
|
||||
close (fd);
|
||||
mctest_assert_int_ne (fd, -1);
|
||||
fail_unless (g_file_test (pname, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR),
|
||||
"\nNo such file: %s\n", pname);
|
||||
unlink (pname);
|
||||
fail_unless (strncmp (pname, begin_pname, strlen (begin_pname)) == 0,
|
||||
"\nstart of %s should be equal to %s\n", pname, begin_pname);
|
||||
g_free (pname);
|
||||
fail_unless (g_file_test
|
||||
(vfs_path_as_str (pname_vpath), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR),
|
||||
"\nNo such file: %s\n", vfs_path_as_str (pname_vpath));
|
||||
unlink (vfs_path_as_str (pname_vpath));
|
||||
fail_unless (strncmp (vfs_path_as_str (pname_vpath), begin_pname, strlen (begin_pname)) == 0,
|
||||
"\nstart of %s should be equal to %s\n", vfs_path_as_str (pname_vpath),
|
||||
begin_pname);
|
||||
vfs_path_free (pname_vpath);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
|
@ -188,7 +188,7 @@ START_PARAMETRIZED_TEST (test_from_to_string, test_from_to_string_ds)
|
||||
|
||||
/* when */
|
||||
vpath_len = vfs_path_elements_count (vpath);
|
||||
actual_result = vfs_path_to_str (vpath);
|
||||
actual_result = vfs_path_as_str (vpath);
|
||||
path_element = vfs_path_get_by_index (vpath, -1);
|
||||
|
||||
/* then */
|
||||
@ -197,7 +197,6 @@ START_PARAMETRIZED_TEST (test_from_to_string, test_from_to_string_ds)
|
||||
mctest_assert_ptr_eq (path_element->class, data->expected_vfs_class);
|
||||
mctest_assert_str_eq (path_element->path, data->expected_element_path);
|
||||
|
||||
g_free (actual_result);
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
@ -298,14 +297,14 @@ START_TEST (test_vfs_path_encoding_at_end)
|
||||
{
|
||||
/* given */
|
||||
vfs_path_t *vpath;
|
||||
char *result;
|
||||
const char *result;
|
||||
const vfs_path_element_t *element;
|
||||
|
||||
vpath =
|
||||
vfs_path_from_str_flags ("/path/to/file.ext#test1:/#enc:KOI8-R", VPF_USE_DEPRECATED_PARSER);
|
||||
|
||||
/* when */
|
||||
result = vfs_path_to_str (vpath);
|
||||
result = vfs_path_as_str (vpath);
|
||||
element = vfs_path_get_by_index (vpath, -1);
|
||||
|
||||
/* then */
|
||||
@ -313,7 +312,6 @@ START_TEST (test_vfs_path_encoding_at_end)
|
||||
mctest_assert_not_null (element->encoding);
|
||||
mctest_assert_str_eq (result, ETALON_STR);
|
||||
|
||||
g_free (result);
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
|
||||
|
@ -47,15 +47,13 @@ test1_mock_open_archive (struct vfs_s_super *super, const vfs_path_t * vpath,
|
||||
const vfs_path_element_t * vpath_element)
|
||||
{
|
||||
struct vfs_s_inode *root;
|
||||
char *spath = vfs_path_to_str (vpath);
|
||||
|
||||
mctest_assert_str_eq (spath, "/" ETALON_VFS_URL_NAME ARCH_NAME);
|
||||
mctest_assert_str_eq (vfs_path_as_str (vpath), "/" ETALON_VFS_URL_NAME ARCH_NAME);
|
||||
|
||||
super->name = g_strdup (spath);
|
||||
super->name = g_strdup (vfs_path_as_str (vpath));
|
||||
super->data = g_new (char *, 1);
|
||||
root = vfs_s_new_inode (vpath_element->class, super, NULL);
|
||||
super->root = root;
|
||||
g_free (spath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -142,13 +142,8 @@ START_PARAMETRIZED_TEST (test_empty_mean_home, test_empty_mean_home_ds)
|
||||
g_free (input_command);
|
||||
}
|
||||
/* then */
|
||||
{
|
||||
char *actual_path;
|
||||
|
||||
actual_path = vfs_path_to_str (do_cd__new_dir_vpath__captured);
|
||||
mctest_assert_str_eq (mc_config_get_home_dir__return_value, actual_path);
|
||||
g_free (actual_path);
|
||||
}
|
||||
mctest_assert_str_eq (mc_config_get_home_dir__return_value,
|
||||
vfs_path_as_str (do_cd__new_dir_vpath__captured));
|
||||
mctest_assert_int_eq (do_cd__cd_type__captured, cd_parse_command);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user