mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-10 21:42:00 +03:00
Merge branch '2781_cleanup' into 4.8.1-stable
* 2781_cleanup: (mc_setup_by_args): fixed memory leaks. (reread_cmd): use vfs_path_cmp() to compare dirs. (do_load_dir): use vfs_path_t as a path handle. README.fish: fixed location of user scripts. Use new-style VFS prefixes. (nice_cd): use new-style VFS prefixes. (input_history_strip_password): actually url is not the pointer to constant. (vfs_expare): changed argument type from int to gboolean. (vfs_url_split): optimized to get rid of multiple string length caclulation. (check_for_default): minor optimization and change return value. (resolve_symlinks): use (vfs_path_t *) as argument. (tty_draw_box): do nothing if width or heigth of box is less than 1. (vfs_path_element_clone): ret rid of extra actions. (vfs_get_raw_current_dir): return pointer to constant. g_dirname and g_basename function are deprecated since glib-2.2. Ticket #2781: cleanup before 4.8.3 release.
This commit is contained in:
commit
dd6340c993
@ -112,7 +112,7 @@ Muestra la versión del programa.
|
||||
Fuerza el modo xterm. Usado cuando se ejecuta en terminales con características de xterm (dos
|
||||
modos de pantalla, y pueden enviar secuencias de escape de ratón).
|
||||
.TP
|
||||
.I \-X, \-\-no\-x
|
||||
.I \-X, \-\-no\-x11
|
||||
Do not use X11 to get the state of modifiers Alt, Ctrl, Shift
|
||||
.TP
|
||||
.I \-g, \-\-oldmouse
|
||||
|
@ -101,7 +101,7 @@ Megmutatja a program verziószámát.
|
||||
Belép xterm módba. (Két képernyős módban használható, és az egér escape
|
||||
szekvenciái is használhatóak).
|
||||
.TP
|
||||
.I \-X, \-\-no\-x
|
||||
.I \-X, \-\-no\-x11
|
||||
Do not use X11 to get the state of modifiers Alt, Ctrl, Shift
|
||||
.TP
|
||||
.I \-g, \-\-oldmouse
|
||||
|
@ -119,7 +119,7 @@ Forza la modalità xterm. Usata quando è in funzione su terminali
|
||||
abilitati\-xterm (due modalità video e in grado di spedire sequenze
|
||||
mouse di escape).
|
||||
.TP
|
||||
.I \-X, \-\-no\-x
|
||||
.I \-X, \-\-no\-x11
|
||||
Do not use X11 to get the state of modifiers Alt, Ctrl, Shift
|
||||
.TP
|
||||
.I \-g, \-\-oldmouse
|
||||
|
@ -160,7 +160,7 @@ Display the version of the program.
|
||||
Force xterm mode. Used when running on xterm\-capable terminals (two
|
||||
screen modes, and able to send mouse escape sequences).
|
||||
.TP
|
||||
.I \-X, \-\-no\-x
|
||||
.I \-X, \-\-no\-x11
|
||||
Do not use X11 to get the state of modifiers Alt, Ctrl, Shift
|
||||
.TP
|
||||
.I \-g, \-\-oldmouse
|
||||
|
@ -104,7 +104,7 @@ Wyświetla wersję programu.
|
||||
Wymusza włączenie trybu xterm. Używane kiedy działa się na terminalach wyposażonych
|
||||
w opcje xterm (dwa tryby ekranu i możliwość wysyłania myszą sygnałów wyjścia).
|
||||
.TP
|
||||
.I \-X, \-\-no\-x
|
||||
.I \-X, \-\-no\-x11
|
||||
Do not use X11 to get the state of modifiers Alt, Ctrl, Shift
|
||||
.TP
|
||||
.I \-g, \-\-oldmouse
|
||||
|
@ -140,7 +140,7 @@ terminfo: в этом случае Midnight Commander использует зн
|
||||
формировать экранирующие последовательности с помощью мыши) (two screen
|
||||
modes, and able to send mouse escape sequences).
|
||||
.TP
|
||||
.I \-X, \-\-no\-x
|
||||
.I \-X, \-\-no\-x11
|
||||
Не использовать X11 для получения состояния модификаторов Alt, Ctrl, Shift.
|
||||
.TP
|
||||
.I \-g, \-\-oldmouse
|
||||
|
@ -99,7 +99,7 @@ termcap/terminfo. Корисно је само на ХП\-овим термин
|
||||
терминалима који имају подршку за Икс терминале (два екранска режима,
|
||||
и могућност слања мишјих комбинација избегавања).
|
||||
.TP
|
||||
.I \-X, \-\-no\-x
|
||||
.I \-X, \-\-no\-x11
|
||||
Do not use X11 to get the state of modifiers Alt, Ctrl, Shift
|
||||
.TP
|
||||
.I \-g, \-\-oldmouse
|
||||
|
11
lib/lock.c
11
lib/lock.c
@ -115,17 +115,18 @@ lock_build_name (void)
|
||||
static char *
|
||||
lock_build_symlink_name (const vfs_path_t * fname_vpath)
|
||||
{
|
||||
const char *elpath, *str_filename;
|
||||
char *str_dirname, *symlink_name;
|
||||
const char *elpath;
|
||||
char *str_filename, *str_dirname, *symlink_name;
|
||||
|
||||
/* get first path piece */
|
||||
elpath = vfs_path_get_by_index (fname_vpath, 0)->path;
|
||||
|
||||
str_filename = g_basename (elpath);
|
||||
str_dirname = g_dirname (elpath);
|
||||
|
||||
str_filename = g_path_get_basename (elpath);
|
||||
str_dirname = g_path_get_dirname (elpath);
|
||||
symlink_name = g_strconcat (str_dirname, PATH_SEP_STR ".#", str_filename, (char *) NULL);
|
||||
g_free (str_dirname);
|
||||
g_free (str_filename);
|
||||
|
||||
return symlink_name;
|
||||
}
|
||||
|
||||
|
@ -177,6 +177,9 @@ tty_print_one_vline (gboolean single)
|
||||
void
|
||||
tty_draw_box (int y, int x, int ys, int xs, gboolean single)
|
||||
{
|
||||
if (ys <= 0 || xs <= 0)
|
||||
return;
|
||||
|
||||
ys--;
|
||||
xs--;
|
||||
|
||||
|
48
lib/util.c
48
lib/util.c
@ -110,25 +110,22 @@ is_8bit_printable (unsigned char c)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static char *
|
||||
resolve_symlinks (const char *path)
|
||||
resolve_symlinks (const vfs_path_t *vpath)
|
||||
{
|
||||
char *p;
|
||||
char *buf, *buf2, *q, *r, c;
|
||||
int len;
|
||||
struct stat mybuf;
|
||||
const char *p;
|
||||
vfs_path_t *vpath;
|
||||
|
||||
if (*path != PATH_SEP)
|
||||
if (vpath->relative)
|
||||
return NULL;
|
||||
|
||||
vpath = vfs_path_from_str (path);
|
||||
p = vfs_path_to_str (vpath);
|
||||
r = buf = g_malloc (MC_MAXPATHLEN);
|
||||
buf2 = g_malloc (MC_MAXPATHLEN);
|
||||
*r++ = PATH_SEP;
|
||||
*r = 0;
|
||||
p = path;
|
||||
|
||||
for (;;)
|
||||
do
|
||||
{
|
||||
q = strchr (p + 1, PATH_SEP);
|
||||
if (!q)
|
||||
@ -143,19 +140,19 @@ resolve_symlinks (const char *path)
|
||||
{
|
||||
g_free (buf);
|
||||
buf = NULL;
|
||||
*q = c;
|
||||
goto ret;
|
||||
}
|
||||
if (!S_ISLNK (mybuf.st_mode))
|
||||
strcpy (r, p + 1);
|
||||
else
|
||||
{
|
||||
int len;
|
||||
|
||||
len = mc_readlink (vpath, buf2, MC_MAXPATHLEN - 1);
|
||||
if (len < 0)
|
||||
{
|
||||
g_free (buf);
|
||||
buf = NULL;
|
||||
*q = c;
|
||||
goto ret;
|
||||
}
|
||||
buf2[len] = 0;
|
||||
@ -167,15 +164,16 @@ resolve_symlinks (const char *path)
|
||||
canonicalize_pathname (buf);
|
||||
r = strchr (buf, 0);
|
||||
if (!*r || *(r - 1) != PATH_SEP)
|
||||
/* FIXME: this condition is always true because r points to the EOL */
|
||||
{
|
||||
*r++ = PATH_SEP;
|
||||
*r = 0;
|
||||
}
|
||||
*q = c;
|
||||
p = q;
|
||||
if (!c)
|
||||
break;
|
||||
}
|
||||
while (c != '\0');
|
||||
|
||||
if (!*buf)
|
||||
strcpy (buf, PATH_SEP_STR);
|
||||
else if (*(r - 1) == PATH_SEP && r != buf + 1)
|
||||
@ -183,7 +181,7 @@ resolve_symlinks (const char *path)
|
||||
|
||||
ret:
|
||||
g_free (buf2);
|
||||
vfs_path_free (vpath);
|
||||
g_free (p);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@ -977,22 +975,14 @@ diff_two_paths (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
|
||||
char *p, *q, *r, *s, *buf = NULL;
|
||||
int i, j, prevlen = -1, currlen;
|
||||
char *my_first = NULL, *my_second = NULL;
|
||||
char *path_str;
|
||||
|
||||
path_str = vfs_path_to_str (vpath1);
|
||||
my_first = resolve_symlinks (path_str);
|
||||
g_free (path_str);
|
||||
my_first = resolve_symlinks (vpath1);
|
||||
if (my_first == NULL)
|
||||
return NULL;
|
||||
goto ret;
|
||||
|
||||
path_str = vfs_path_to_str (vpath2);
|
||||
my_second = resolve_symlinks (path_str);
|
||||
g_free (path_str);
|
||||
my_second = resolve_symlinks (vpath2);
|
||||
if (my_second == NULL)
|
||||
{
|
||||
g_free (my_first);
|
||||
return NULL;
|
||||
}
|
||||
goto ret;
|
||||
|
||||
for (j = 0; j < 2; j++)
|
||||
{
|
||||
@ -1028,11 +1018,7 @@ diff_two_paths (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
|
||||
if (currlen < prevlen)
|
||||
g_free (buf);
|
||||
else
|
||||
{
|
||||
g_free (my_first);
|
||||
g_free (my_second);
|
||||
return buf;
|
||||
}
|
||||
goto ret;
|
||||
}
|
||||
p = buf = g_malloc (currlen);
|
||||
prevlen = currlen;
|
||||
@ -1040,6 +1026,8 @@ diff_two_paths (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
|
||||
strcpy (p, "../");
|
||||
strcpy (p, q);
|
||||
}
|
||||
|
||||
ret:
|
||||
g_free (my_first);
|
||||
g_free (my_second);
|
||||
return buf;
|
||||
|
15
lib/vfs/gc.c
15
lib/vfs/gc.c
@ -182,7 +182,7 @@ vfs_stamp_create (struct vfs_class *vclass, vfsid id)
|
||||
vfsid nvfsid;
|
||||
|
||||
ev_vfs_stamp_create_t event_data = { vclass, id, FALSE };
|
||||
vfs_path_t *vpath;
|
||||
const vfs_path_t *vpath;
|
||||
const vfs_path_element_t *path_element;
|
||||
|
||||
/* There are three directories we have to take care of: current_dir,
|
||||
@ -214,9 +214,9 @@ vfs_stamp_create (struct vfs_class *vclass, vfsid id)
|
||||
with now = 1 to force freeing all filesystems that are not in use */
|
||||
|
||||
void
|
||||
vfs_expire (int now)
|
||||
vfs_expire (gboolean now)
|
||||
{
|
||||
static int locked = 0;
|
||||
static gboolean locked = FALSE;
|
||||
struct timeval lc_time;
|
||||
struct vfs_stamping *stamp, *st;
|
||||
|
||||
@ -224,7 +224,7 @@ vfs_expire (int now)
|
||||
calls message */
|
||||
if (locked)
|
||||
return;
|
||||
locked = 1;
|
||||
locked = TRUE;
|
||||
|
||||
gettimeofday (&lc_time, NULL);
|
||||
lc_time.tv_sec -= vfs_timeout;
|
||||
@ -242,7 +242,8 @@ vfs_expire (int now)
|
||||
else
|
||||
stamp = stamp->next;
|
||||
}
|
||||
locked = 0;
|
||||
|
||||
locked = FALSE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -253,7 +254,7 @@ vfs_expire (int now)
|
||||
*/
|
||||
|
||||
int
|
||||
vfs_timeouts ()
|
||||
vfs_timeouts (void)
|
||||
{
|
||||
return stamps ? 10 : 0;
|
||||
}
|
||||
@ -263,7 +264,7 @@ vfs_timeouts ()
|
||||
void
|
||||
vfs_timeout_handler (void)
|
||||
{
|
||||
vfs_expire (0);
|
||||
vfs_expire (FALSE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -838,17 +838,22 @@ vfs_path_get_by_index (const vfs_path_t * vpath, int element_index)
|
||||
vfs_path_element_t *
|
||||
vfs_path_element_clone (const vfs_path_element_t * element)
|
||||
{
|
||||
vfs_path_element_t *new_element = g_new0 (vfs_path_element_t, 1);
|
||||
memcpy (new_element, element, sizeof (vfs_path_element_t));
|
||||
vfs_path_element_t *new_element = g_new (vfs_path_element_t, 1);
|
||||
|
||||
new_element->user = g_strdup (element->user);
|
||||
new_element->password = g_strdup (element->password);
|
||||
new_element->host = g_strdup (element->host);
|
||||
new_element->ipv6 = element->ipv6;
|
||||
new_element->port = element->port;
|
||||
new_element->path = g_strdup (element->path);
|
||||
new_element->class = element->class;
|
||||
new_element->encoding = g_strdup (element->encoding);
|
||||
new_element->vfs_prefix = g_strdup (element->vfs_prefix);
|
||||
if (vfs_path_element_need_cleanup_converter (element) && new_element->encoding != NULL)
|
||||
new_element->dir.converter = str_crt_conv_from (new_element->encoding);
|
||||
new_element->vfs_prefix = g_strdup (element->vfs_prefix);
|
||||
else
|
||||
new_element->dir.converter = element->dir.converter;
|
||||
new_element->dir.info = element->dir.info;
|
||||
|
||||
return new_element;
|
||||
}
|
||||
|
@ -230,14 +230,16 @@ vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags)
|
||||
vfs_path_element_t *path_element;
|
||||
|
||||
char *pcopy;
|
||||
size_t pcopy_len;
|
||||
const char *pend;
|
||||
char *dir, *colon, *inner_colon, *at, *rest;
|
||||
|
||||
path_element = g_new0 (vfs_path_element_t, 1);
|
||||
path_element->port = default_port;
|
||||
|
||||
pcopy = g_strdup (path);
|
||||
pend = pcopy + strlen (pcopy);
|
||||
pcopy_len = strlen (path);
|
||||
pcopy = g_strndup (path, pcopy_len);
|
||||
pend = pcopy + pcopy_len;
|
||||
dir = pcopy;
|
||||
|
||||
if ((flags & URL_NOSLASH) == 0)
|
||||
@ -249,7 +251,7 @@ vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags)
|
||||
path_element->path = g_strdup (PATH_SEP_STR);
|
||||
else
|
||||
{
|
||||
path_element->path = g_strdup (dir);
|
||||
path_element->path = g_strndup (dir, pcopy_len - (size_t) (dir - pcopy));
|
||||
*dir = '\0';
|
||||
}
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ vfs_get_current_dir (void)
|
||||
* @return object contain current path
|
||||
*/
|
||||
|
||||
vfs_path_t *
|
||||
const vfs_path_t *
|
||||
vfs_get_raw_current_dir (void)
|
||||
{
|
||||
return current_path;
|
||||
|
@ -229,10 +229,10 @@ void vfs_setup_work_dir (void);
|
||||
|
||||
void vfs_timeout_handler (void);
|
||||
int vfs_timeouts (void);
|
||||
void vfs_expire (int now);
|
||||
void vfs_expire (gboolean now);
|
||||
|
||||
char *vfs_get_current_dir (void);
|
||||
vfs_path_t *vfs_get_raw_current_dir (void);
|
||||
const vfs_path_t *vfs_get_raw_current_dir (void);
|
||||
void vfs_set_raw_current_dir (const vfs_path_t * vpath);
|
||||
|
||||
gboolean vfs_current_is_local (void);
|
||||
|
@ -211,7 +211,7 @@ do_show_hist (WInput * in)
|
||||
*/
|
||||
|
||||
static char *
|
||||
input_history_strip_password (const char *url)
|
||||
input_history_strip_password (char *url)
|
||||
{
|
||||
char *at, *delim, *colon;
|
||||
|
||||
|
@ -654,6 +654,7 @@ mc_setup_by_args (int argc, char **argv, GError ** error)
|
||||
char *fname;
|
||||
struct stat st;
|
||||
vfs_path_t *tmp_vpath, *fname_vpath;
|
||||
gboolean ok;
|
||||
|
||||
fname = g_strndup (tmp, p - 1 - tmp);
|
||||
tmp_vpath = vfs_path_from_str (tmp);
|
||||
@ -662,7 +663,11 @@ mc_setup_by_args (int argc, char **argv, GError ** error)
|
||||
* Check that the file before the colon actually exists.
|
||||
* If it doesn't exist, revert to the old behavior.
|
||||
*/
|
||||
if (mc_stat (tmp_vpath, &st) == -1 && mc_stat (fname_vpath, &st) != -1)
|
||||
ok = mc_stat (tmp_vpath, &st) == -1 && mc_stat (fname_vpath, &st) != -1;
|
||||
vfs_path_free (tmp_vpath);
|
||||
vfs_path_free (fname_vpath);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
mc_run_param0 = fname;
|
||||
mc_args__edit_start_line = atoi (p);
|
||||
@ -672,8 +677,6 @@ mc_setup_by_args (int argc, char **argv, GError ** error)
|
||||
g_free (fname);
|
||||
goto try_plus_filename;
|
||||
}
|
||||
vfs_path_free (tmp_vpath);
|
||||
vfs_path_free (fname_vpath);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -520,23 +520,6 @@ do_link (link_type_t link_type, const char *fname)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#if defined(ENABLE_VFS_UNDELFS) || defined(ENABLE_VFS_NET)
|
||||
|
||||
static const char *
|
||||
transform_prefix (const char *prefix)
|
||||
{
|
||||
static char buffer[BUF_TINY];
|
||||
size_t prefix_len = strlen (prefix);
|
||||
|
||||
if (prefix_len < 3)
|
||||
return prefix;
|
||||
|
||||
strcpy (buffer, prefix + 2);
|
||||
strcpy (buffer + prefix_len - 3, VFS_PATH_URL_DELIMITER);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
nice_cd (const char *text, const char *xtext, const char *help,
|
||||
const char *history_name, const char *prefix, int to_home, gboolean strip_password)
|
||||
@ -548,21 +531,19 @@ nice_cd (const char *text, const char *xtext, const char *help,
|
||||
return;
|
||||
|
||||
machine = input_dialog_help (text, xtext, help, history_name, "", strip_password);
|
||||
if (!machine)
|
||||
if (machine == NULL)
|
||||
return;
|
||||
|
||||
to_home = 0; /* FIXME: how to solve going to home nicely? /~/ is
|
||||
ugly as hell and leads to problems in vfs layer */
|
||||
|
||||
/* default prefix in old-style format. */
|
||||
if (strncmp (prefix, machine, strlen (prefix)) != 0)
|
||||
prefix = transform_prefix (prefix); /* Convert prefix to URL-style format */
|
||||
|
||||
if (strncmp (prefix, machine, strlen (prefix)) == 0)
|
||||
cd_path = g_strconcat (machine, to_home ? "/~/" : (char *) NULL, (char *) NULL);
|
||||
else
|
||||
cd_path = g_strconcat (prefix, machine, to_home ? "/~/" : (char *) NULL, (char *) NULL);
|
||||
|
||||
g_free (machine);
|
||||
|
||||
if (*cd_path != PATH_SEP)
|
||||
{
|
||||
char *tmp = cd_path;
|
||||
@ -580,7 +561,6 @@ nice_cd (const char *text, const char *xtext, const char *help,
|
||||
vfs_path_free (cd_vpath);
|
||||
}
|
||||
g_free (cd_path);
|
||||
g_free (machine);
|
||||
}
|
||||
#endif /* ENABLE_VFS_UNDELFS || ENABLE_VFS_NET */
|
||||
|
||||
@ -1058,19 +1038,9 @@ reread_cmd (void)
|
||||
{
|
||||
panel_update_flags_t flag = UP_ONLY_CURRENT;
|
||||
|
||||
if (get_current_type () == view_listing && get_other_type () == view_listing)
|
||||
{
|
||||
char *c_cwd, *o_cwd;
|
||||
|
||||
c_cwd = vfs_path_to_str (current_panel->cwd_vpath);
|
||||
o_cwd = vfs_path_to_str (other_panel->cwd_vpath);
|
||||
|
||||
if (strcmp (c_cwd, o_cwd) == 0)
|
||||
flag = UP_OPTIMIZE;
|
||||
|
||||
g_free (c_cwd);
|
||||
g_free (o_cwd);
|
||||
}
|
||||
if (get_current_type () == view_listing && get_other_type () == view_listing &&
|
||||
vfs_path_cmp (current_panel->cwd_vpath, other_panel->cwd_vpath) == 0)
|
||||
flag = UP_OPTIMIZE;
|
||||
|
||||
update_panels (UP_RELOAD | flag, UP_KEEPSEL);
|
||||
repaint_screen ();
|
||||
@ -1531,13 +1501,12 @@ get_random_hint (int force)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef ENABLE_VFS_NET
|
||||
#ifdef ENABLE_VFS_FTP
|
||||
void
|
||||
ftplink_cmd (void)
|
||||
{
|
||||
nice_cd (_("FTP to machine"), _(machine_str),
|
||||
"[FTP File System]", ":ftplink_cmd: FTP to machine ", "/#ftp:", 1, TRUE);
|
||||
"[FTP File System]", ":ftplink_cmd: FTP to machine ", "ftp://", 1, TRUE);
|
||||
}
|
||||
#endif /* ENABLE_VFS_FTP */
|
||||
|
||||
@ -1549,7 +1518,7 @@ fishlink_cmd (void)
|
||||
{
|
||||
nice_cd (_("Shell link to machine"), _(machine_str),
|
||||
"[FIle transfer over SHell filesystem]", ":fishlink_cmd: Shell link to machine ",
|
||||
"/#sh:", 1, TRUE);
|
||||
"sh://", 1, TRUE);
|
||||
}
|
||||
#endif /* ENABLE_VFS_FISH */
|
||||
|
||||
@ -1560,10 +1529,9 @@ void
|
||||
smblink_cmd (void)
|
||||
{
|
||||
nice_cd (_("SMB link to machine"), _(machine_str),
|
||||
"[SMB File System]", ":smblink_cmd: SMB link to machine ", "/#smb:", 0, TRUE);
|
||||
"[SMB File System]", ":smblink_cmd: SMB link to machine ", "smb://", 0, TRUE);
|
||||
}
|
||||
#endif /* ENABLE_VFS_SMB */
|
||||
#endif /* ENABLE_VFS_NET */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
@ -1573,7 +1541,7 @@ undelete_cmd (void)
|
||||
{
|
||||
nice_cd (_("Undelete files on an ext2 file system"),
|
||||
_("Enter device (without /dev/) to undelete\nfiles on: (F1 for details)"),
|
||||
"[Undelete File System]", ":undelete_cmd: Undel on ext2 fs ", "/#undel:", 0, FALSE);
|
||||
"[Undelete File System]", ":undelete_cmd: Undel on ext2 fs ", "undel://", 0, FALSE);
|
||||
}
|
||||
#endif /* ENABLE_VFS_UNDELFS */
|
||||
|
||||
|
@ -533,7 +533,7 @@ handle_path (dir_list * list, const char *path,
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
do_load_dir (const char *path, dir_list * list, sortfn * sort, gboolean lc_reverse,
|
||||
do_load_dir (const vfs_path_t * vpath, dir_list * list, sortfn * sort, gboolean lc_reverse,
|
||||
gboolean lc_case_sensitive, gboolean exec_ff, const char *fltr)
|
||||
{
|
||||
DIR *dirp;
|
||||
@ -541,13 +541,12 @@ do_load_dir (const char *path, dir_list * list, sortfn * sort, gboolean lc_rever
|
||||
int status, link_to_dir, stale_link;
|
||||
int next_free = 0;
|
||||
struct stat st;
|
||||
vfs_path_t *vpath;
|
||||
char *path;
|
||||
|
||||
/* ".." (if any) must be the first entry in the list */
|
||||
if (!set_zero_dir (list))
|
||||
return next_free;
|
||||
|
||||
vpath = vfs_path_from_str (path);
|
||||
if (get_dotdot_dir_stat (vpath, &st))
|
||||
list->list[next_free].st = st;
|
||||
next_free++;
|
||||
@ -556,26 +555,25 @@ do_load_dir (const char *path, dir_list * list, sortfn * sort, gboolean lc_rever
|
||||
if (dirp == NULL)
|
||||
{
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot read directory contents"));
|
||||
goto ret;
|
||||
return next_free;
|
||||
}
|
||||
|
||||
tree_store_start_check (vpath);
|
||||
|
||||
/* Do not add a ".." entry to the root directory */
|
||||
path = vfs_path_to_str (vpath);
|
||||
if ((path[0] == PATH_SEP) && (path[1] == '\0'))
|
||||
next_free--;
|
||||
g_free (path);
|
||||
|
||||
while ((dp = mc_readdir (dirp)))
|
||||
while ((dp = mc_readdir (dirp)) != NULL)
|
||||
{
|
||||
status = handle_dirent (list, fltr, dp, &st, next_free, &link_to_dir, &stale_link);
|
||||
if (status == 0)
|
||||
continue;
|
||||
if (status == -1)
|
||||
{
|
||||
tree_store_end_check ();
|
||||
mc_closedir (dirp);
|
||||
goto ret;
|
||||
}
|
||||
|
||||
list->list[next_free].fnamelen = NLENGTH (dp);
|
||||
list->list[next_free].fname = g_strndup (dp->d_name, list->list[next_free].fnamelen);
|
||||
list->list[next_free].f.marked = 0;
|
||||
@ -594,10 +592,9 @@ do_load_dir (const char *path, dir_list * list, sortfn * sort, gboolean lc_rever
|
||||
if (next_free != 0)
|
||||
do_sort (list, sort, next_free - 1, lc_reverse, lc_case_sensitive, exec_ff);
|
||||
|
||||
ret:
|
||||
mc_closedir (dirp);
|
||||
tree_store_end_check ();
|
||||
ret:
|
||||
vfs_path_free (vpath);
|
||||
return next_free;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ typedef struct
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
int do_load_dir (const char *path, dir_list * list, sortfn * sort, gboolean reverse,
|
||||
int do_load_dir (const vfs_path_t * vpath, dir_list * list, sortfn * sort, gboolean reverse,
|
||||
gboolean case_sensitive, gboolean exec_ff, const char *fltr);
|
||||
void do_sort (dir_list * list, sortfn * sort, int top, gboolean reverse,
|
||||
gboolean case_sensitive, gboolean exec_ff);
|
||||
|
@ -504,7 +504,7 @@ hotlist_button_callback (WButton * button, int action)
|
||||
|
||||
#ifdef ENABLE_VFS
|
||||
case B_FREE_ALL_VFS:
|
||||
vfs_expire (1);
|
||||
vfs_expire (TRUE);
|
||||
/* fall through */
|
||||
|
||||
case B_REFRESH_VFS:
|
||||
|
@ -2916,17 +2916,19 @@ _do_panel_cd (WPanel * panel, const vfs_path_t * new_dir_vpath, enum cd_enum cd_
|
||||
|
||||
/* Reload current panel */
|
||||
panel_clean_dir (panel);
|
||||
|
||||
{
|
||||
char *tmp_path;
|
||||
|
||||
tmp_path = vfs_path_to_str (panel->cwd_vpath);
|
||||
panel->count =
|
||||
do_load_dir (tmp_path, &panel->dir, panel->sort_info.sort_field->sort_routine,
|
||||
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);
|
||||
}
|
||||
|
||||
load_hint (0);
|
||||
panel->dirty = 1;
|
||||
update_xterm_title_path ();
|
||||
@ -3981,16 +3983,10 @@ panel_new_with_dir (const char *panel_name, const char *wpath)
|
||||
}
|
||||
|
||||
/* Load the default format */
|
||||
{
|
||||
char *tmp_path;
|
||||
|
||||
tmp_path = vfs_path_to_str (panel->cwd_vpath);
|
||||
panel->count =
|
||||
do_load_dir (tmp_path, &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);
|
||||
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);
|
||||
|
||||
/* Restore old right path */
|
||||
if (curdir != NULL)
|
||||
|
16
src/util.c
16
src/util.c
@ -48,24 +48,25 @@
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
gboolean
|
||||
check_for_default (const vfs_path_t * default_file_vpath, const vfs_path_t * file_vpath)
|
||||
{
|
||||
char *file, *default_file;
|
||||
char *file;
|
||||
|
||||
file = vfs_path_to_str (file_vpath);
|
||||
default_file = vfs_path_to_str (default_file_vpath);
|
||||
|
||||
if (!exist_file (file))
|
||||
{
|
||||
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);
|
||||
return -1;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ctx = file_op_context_new (OP_COPY);
|
||||
@ -74,11 +75,12 @@ check_for_default (const vfs_path_t * default_file_vpath, const vfs_path_t * fil
|
||||
copy_file_file (tctx, ctx, default_file, file);
|
||||
file_op_total_context_destroy (tctx);
|
||||
file_op_context_destroy (ctx);
|
||||
g_free (default_file);
|
||||
}
|
||||
g_free (file);
|
||||
g_free (default_file);
|
||||
|
||||
return 0;
|
||||
g_free (file);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -12,7 +12,7 @@
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
/* Check if the file exists. If not copy the default */
|
||||
int check_for_default (const vfs_path_t * default_file_vpath, const vfs_path_t * file_vpath);
|
||||
gboolean check_for_default (const vfs_path_t * default_file_vpath, const vfs_path_t * file_vpath);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
* Derived from ftpfs.c
|
||||
* Read README.fish for protocol specification.
|
||||
*
|
||||
* Syntax of path is: \verbatim /#sh:user@host[:Cr]/path \endverbatim
|
||||
* Syntax of path is: \verbatim sh://user@host[:Cr]/path \endverbatim
|
||||
* where C means you want compressed connection,
|
||||
* and r means you want to use rsh
|
||||
*
|
||||
@ -546,7 +546,7 @@ fish_open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
|
||||
vfs_print_message (_("fish: Connected, home %s."), super->path_element->path);
|
||||
#if 0
|
||||
super->name =
|
||||
g_strconcat ("/#sh:", super->path_element->user, "@", super->path_element->host, "/",
|
||||
g_strconcat ("sh://", super->path_element->user, "@", super->path_element->host, "/",
|
||||
(char *) NULL);
|
||||
#else
|
||||
super->name = g_strdup (PATH_SEP_STR);
|
||||
|
@ -24,12 +24,12 @@ Commander source code.
|
||||
|
||||
First, mc looks for system-wide set of scripts, then it checks whether
|
||||
current user has host-specific overrides in his per-user mc
|
||||
configuration folder. User-defined overrides take priority over
|
||||
sytem-wide scripts if they exist. The order in which the folders are
|
||||
configuration directory. User-defined overrides take priority over
|
||||
sytem-wide scripts if they exist. The order in which the directories are
|
||||
traversed is as follows:
|
||||
|
||||
/usr/libexec/mc/fish
|
||||
~/.mc/fish/<hostname>/
|
||||
~/.local/share/mc/fish/<hostname>/
|
||||
|
||||
Server's reply is multiline, but always ends with
|
||||
|
||||
|
@ -54,11 +54,11 @@ What to do with this?
|
||||
|
||||
* NOTE: Usage of tildes is deprecated, consider:
|
||||
* \verbatim
|
||||
cd /#ftp:pavel@hobit
|
||||
cd ftp//:pavel@hobit
|
||||
cd ~
|
||||
\endverbatim
|
||||
* And now: what do I want to do? Do I want to go to /home/pavel or to
|
||||
* /#ftp:hobit/home/pavel? I think first has better sense...
|
||||
* ftp://hobit/home/pavel? I think first has better sense...
|
||||
*
|
||||
\verbatim
|
||||
{
|
||||
|
@ -160,7 +160,7 @@ undelfs_get_path (const vfs_path_t * vpath, char **fsname, char **file)
|
||||
path_element = vfs_path_get_by_index (vpath, -1);
|
||||
|
||||
/* To look like filesystem, we have virtual directories
|
||||
/#undel:XXX, which have no subdirectories. XXX is replaced with
|
||||
undel://XXX, which have no subdirectories. XXX is replaced with
|
||||
hda5, sdb8 etc, which is assumed to live under /dev.
|
||||
-- pavel@ucw.cz */
|
||||
|
||||
@ -168,7 +168,7 @@ undelfs_get_path (const vfs_path_t * vpath, char **fsname, char **file)
|
||||
|
||||
*fsname = NULL;
|
||||
|
||||
if (strncmp (dirname, "/#undel", 7))
|
||||
if (strncmp (dirname, "undel://", 8) != 0)
|
||||
return;
|
||||
|
||||
dirname += 8;
|
||||
@ -202,7 +202,6 @@ undelfs_get_path (const vfs_path_t * vpath, char **fsname, char **file)
|
||||
}
|
||||
*file = g_strdup ("");
|
||||
*fsname = g_strconcat ("/dev/", dirname, (char *) NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -136,10 +136,10 @@ get_panel_widget (int idx)
|
||||
|
||||
|
||||
int
|
||||
do_load_dir (const char *path, dir_list * list, sortfn * sort, gboolean reverse,
|
||||
do_load_dir (const vfs_path_t *vpath, dir_list * list, sortfn * sort, gboolean reverse,
|
||||
gboolean case_sensitive, gboolean exec_ff, const char *fltr)
|
||||
{
|
||||
(void) path;
|
||||
(void) vpath;
|
||||
(void) list;
|
||||
(void) sort;
|
||||
(void) reverse;
|
||||
|
Loading…
Reference in New Issue
Block a user