Browse Source

Merge fs functions

master
Arun Prakash Jana 6 years ago
parent
commit
65aa62c48e
No known key found for this signature in database GPG Key ID: A75979F35C080412
1 changed files with 11 additions and 15 deletions
  1. +11
    -15
      nnn.c

+ 11
- 15
nnn.c View File

@@ -175,6 +175,10 @@ disabledbg()
#define POLYNOMIAL 0xD8 /* 11011 followed by 0's */ #define POLYNOMIAL 0xD8 /* 11011 followed by 0's */
#define CRC8_TABLE_LEN 256 #define CRC8_TABLE_LEN 256


/* Volume info */
#define FREE 0
#define CAPACITY 1

/* Function macros */ /* Function macros */
#define exitcurses() endwin() #define exitcurses() endwin()
#define clearprompt() printmsg("") #define clearprompt() printmsg("")
@@ -1863,25 +1867,17 @@ show_stats(char *fpath, char *fname, struct stat *sb)
} }


static size_t static size_t
get_fs_free(const char *path)
get_fs_info(const char *path, bool type)
{ {
static struct statvfs svb; static struct statvfs svb;


if (statvfs(path, &svb) == -1) if (statvfs(path, &svb) == -1)
return 0; return 0;
else
return svb.f_bavail << ffs(svb.f_frsize >> 1);
}

static size_t
get_fs_capacity(const char *path)
{
struct statvfs svb;


if (statvfs(path, &svb) == -1)
return 0;
else
if (type == CAPACITY)
return svb.f_blocks << ffs(svb.f_bsize >> 1); return svb.f_blocks << ffs(svb.f_bsize >> 1);
else
return svb.f_bavail << ffs(svb.f_frsize >> 1);
} }


static int static int
@@ -1996,8 +1992,8 @@ show_help(char *path)
start = ++end; start = ++end;
} }


dprintf(fd, "\nVolume: %s of ", coolsize(get_fs_free(path)));
dprintf(fd, "%s free\n\n", coolsize(get_fs_capacity(path)));
dprintf(fd, "\nVolume: %s of ", coolsize(get_fs_info(path, FREE)));
dprintf(fd, "%s free\n\n", coolsize(get_fs_info(path, CAPACITY)));


if (getenv("NNN_BMS")) { if (getenv("NNN_BMS")) {
dprintf(fd, "BOOKMARKS\n"); dprintf(fd, "BOOKMARKS\n");
@@ -2397,7 +2393,7 @@ redraw(char *path)
else { else {
i = snprintf(buf, 64, "%d/%d du: %s (%lu files) ", cur + 1, ndents, coolsize(dir_blocks << 9), num_files); i = snprintf(buf, 64, "%d/%d du: %s (%lu files) ", cur + 1, ndents, coolsize(dir_blocks << 9), num_files);
snprintf(buf + i, NAME_MAX, "vol: %s free [%s%s]", snprintf(buf + i, NAME_MAX, "vol: %s free [%s%s]",
coolsize(get_fs_free(path)), unescape(dents[cur].name, 0), get_file_sym(dents[cur].mode));
coolsize(get_fs_info(path, FREE)), unescape(dents[cur].name, 0), get_file_sym(dents[cur].mode));
} }


printmsg(buf); printmsg(buf);


Loading…
Cancel
Save