Re: [RFE][PATCH] Display free space on device in panels



Jindrich Novy wrote:
> --- mc-4.6.1a/src/screen.c.showfree	2005-12-28 16:49:52.000000000 +0100
> +++ mc-4.6.1a/src/screen.c	2005-12-28 17:14:45.000000000 +0100
> @@ -106,6 +107,12 @@ int filetype_mode = 1;
>  /* The hook list for the select file function */
>  Hook *select_file_hook = 0;
>  
> +/* Old current working directory for displaying free space */
> +char *old_cwd = NULL;
> +
> +/* Used to figure out how many free space we have */
> +struct my_statfs myfs_stats;
> +

As these variables are not mentioned in any header file, they should be
"static".

>  static cb_ret_t panel_callback (Widget *, widget_msg_t msg, int parm);
>  static int panel_event (Gpm_Event *event, void *);
>  static void paint_frame (WPanel *panel);
> @@ -851,6 +858,41 @@ paint_dir (WPanel *panel)
>      standend ();
>  }
>  
> +
> +static void
> +show_free_space(WPanel *panel)
> +{
> +    struct stat st;
> +
> +    /* Don't try to stat non-local fs */
> +    if (strlen(panel->cwd) >= 2 && panel->cwd[0] == '/' && panel->cwd[1] == '#')
> +	return;

We have vfs_current_is_local() and vfs_file_is_local(), which should be
used instead of this hack.

> +    if (old_cwd == NULL || strcmp(old_cwd, panel->cwd)) {

Please always compare the result of strcmp() to an integer, in this case 0.

> +	init_my_statfs();
> +	if (old_cwd != NULL) g_free(old_cwd);

The if (...) is unnecessary.

> +	old_cwd = g_strdup(panel->cwd);
> +    }
> +
> +    my_statfs (&myfs_stats, panel->cwd);
> +    st = panel->dir.list [panel->selected].st;
> +	
> +    if (myfs_stats.avail > 0 || myfs_stats.total > 0) {
> +	char buffer1 [6], buffer2[6], *tmp;
> +	size_trunc_len (buffer1, 5, myfs_stats.avail, 1);
> +	size_trunc_len (buffer2, 5, myfs_stats.total, 1);
> +	tmp = g_strdup_printf (_("%s (%d%%) of %s"), buffer1, myfs_stats.total ?

Please compare myfs_stats.total to 0 instead of treating it like a
boolean variable.

Roland



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]