File TODO changed (mode: 100644) (index 1370220d0..7a8c1837b) |
... |
... |
Basic things that need to be done. |
5 |
5 |
Better documentation. |
Better documentation. |
6 |
6 |
Handle commands that are too long to be passed directly to the shell. |
Handle commands that are too long to be passed directly to the shell. |
7 |
7 |
Make ga work in background. |
Make ga work in background. |
8 |
|
Implement ga instead of using du command. |
|
9 |
8 |
Document options. |
Document options. |
10 |
9 |
Add menu for viewing command line history. |
Add menu for viewing command line history. |
11 |
10 |
Replace escape sequences in quick view output with ^foo. |
Replace escape sequences in quick view output with ^foo. |
File src/fileops.c changed (mode: 100644) (index 0669bc70d..397f6402c) |
16 |
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
17 |
17 |
*/ |
*/ |
18 |
18 |
|
|
19 |
|
#include <ncurses.h> |
|
20 |
|
#include <unistd.h> |
|
|
19 |
|
#include <dirent.h> |
21 |
20 |
#include <errno.h> /* errno */ |
#include <errno.h> /* errno */ |
22 |
|
#include <sys/wait.h> /* waitpid() */ |
|
23 |
|
#include <sys/types.h> /* waitpid() */ |
|
24 |
|
#include <sys/stat.h> /* stat */ |
|
|
21 |
|
#include <fcntl.h> |
|
22 |
|
#include <ncurses.h> |
25 |
23 |
#include <stdio.h> |
#include <stdio.h> |
26 |
24 |
#include <string.h> |
#include <string.h> |
27 |
|
#include <fcntl.h> |
|
|
25 |
|
#include <sys/stat.h> /* stat */ |
|
26 |
|
#include <sys/types.h> /* waitpid() */ |
|
27 |
|
#include <sys/wait.h> /* waitpid() */ |
|
28 |
|
#include <unistd.h> |
28 |
29 |
|
|
29 |
30 |
#include "background.h" |
#include "background.h" |
30 |
31 |
#include "color_scheme.h" |
#include "color_scheme.h" |
|
... |
... |
clone_file(FileView* view) |
974 |
975 |
free(escaped); |
free(escaped); |
975 |
976 |
} |
} |
976 |
977 |
|
|
|
978 |
|
unsigned long long |
|
979 |
|
calc_dirsize(const char *path) |
|
980 |
|
{ |
|
981 |
|
DIR* dir; |
|
982 |
|
struct dirent* dentry; |
|
983 |
|
const char* slash = ""; |
|
984 |
|
size_t size; |
|
985 |
|
|
|
986 |
|
dir = opendir(path); |
|
987 |
|
if(dir == NULL) |
|
988 |
|
return (0); |
|
989 |
|
|
|
990 |
|
if(path[strlen(path) - 1] != '/') |
|
991 |
|
slash = "/"; |
|
992 |
|
|
|
993 |
|
size = 0; |
|
994 |
|
while((dentry = readdir(dir)) != NULL) |
|
995 |
|
{ |
|
996 |
|
char buf[PATH_MAX]; |
|
997 |
|
|
|
998 |
|
if(strcmp(dentry->d_name, ".") == 0) |
|
999 |
|
continue; |
|
1000 |
|
else if(strcmp(dentry->d_name, "..") == 0) |
|
1001 |
|
continue; |
|
1002 |
|
|
|
1003 |
|
snprintf(buf, sizeof (buf), "%s%s%s", path, slash, dentry->d_name); |
|
1004 |
|
if(dentry->d_type == DT_DIR) |
|
1005 |
|
{ |
|
1006 |
|
unsigned long long dir_size = (unsigned long long)tree_get_data( |
|
1007 |
|
curr_stats.dirsize_cache, buf); |
|
1008 |
|
if(dir_size == 0) |
|
1009 |
|
dir_size = calc_dirsize(buf); |
|
1010 |
|
size += dir_size; |
|
1011 |
|
} |
|
1012 |
|
else |
|
1013 |
|
{ |
|
1014 |
|
struct stat st; |
|
1015 |
|
if(stat(buf, &st) == 0) |
|
1016 |
|
size += st.st_size; |
|
1017 |
|
} |
|
1018 |
|
} |
|
1019 |
|
|
|
1020 |
|
closedir(dir); |
|
1021 |
|
|
|
1022 |
|
tree_set_data(curr_stats.dirsize_cache, path, (void*)size); |
|
1023 |
|
return (size); |
|
1024 |
|
} |
|
1025 |
|
|
977 |
1026 |
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab : */ |
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab : */ |
File src/fileops.h changed (mode: 100644) (index a31cc0229..c45bcf1b7) |
2 |
2 |
* Copyright (C) 2001 Ken Steen. |
* Copyright (C) 2001 Ken Steen. |
3 |
3 |
* |
* |
4 |
4 |
* This program is free software; you can redistribute it and/or modify |
* This program is free software; you can redistribute it and/or modify |
5 |
|
* it under the terms of the GNU General Public License as published by |
|
6 |
|
* the Free Software Foundation; either version 2 of the License, or |
|
|
5 |
|
* it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or |
7 |
6 |
* (at your option) any later version. |
* (at your option) any later version. |
8 |
7 |
* |
* |
9 |
8 |
* This program is distributed in the hope that it will be useful, |
* This program is distributed in the hope that it will be useful, |
|
... |
... |
void change_group(FileView *view); |
55 |
54 |
/* Returns new value for save_msg flag. */ |
/* Returns new value for save_msg flag. */ |
56 |
55 |
int put_files_from_register(FileView *view, int name, int force_move); |
int put_files_from_register(FileView *view, int name, int force_move); |
57 |
56 |
void clone_file(FileView* view); |
void clone_file(FileView* view); |
|
57 |
|
unsigned long long calc_dirsize(const char *path); |
58 |
58 |
|
|
59 |
59 |
#endif |
#endif |
60 |
60 |
|
|
File src/normal.c changed (mode: 100644) (index 66b7b8795..8090c2fff) |
... |
... |
selector_G(struct key_info key_info, struct keys_info *keys_info) |
730 |
730 |
static void |
static void |
731 |
731 |
cmd_ga(struct key_info key_info, struct keys_info *keys_info) |
cmd_ga(struct key_info key_info, struct keys_info *keys_info) |
732 |
732 |
{ |
{ |
733 |
|
pid_t pid; |
|
734 |
|
int out_pipe[2]; |
|
735 |
|
|
|
736 |
733 |
if(curr_view->dir_entry[curr_view->list_pos].type != DIRECTORY) |
if(curr_view->dir_entry[curr_view->list_pos].type != DIRECTORY) |
737 |
734 |
return; |
return; |
738 |
735 |
|
|
739 |
|
if(pipe(out_pipe) != 0) |
|
740 |
|
{ |
|
741 |
|
show_error_msg(" File pipe error", "Error creating pipe"); |
|
742 |
|
return; |
|
743 |
|
} |
|
|
736 |
|
calc_dirsize(curr_view->dir_entry[curr_view->list_pos].name); |
744 |
737 |
|
|
745 |
|
if((pid = fork()) == -1) |
|
746 |
|
return; |
|
747 |
|
|
|
748 |
|
if(pid == 0) |
|
749 |
|
{ |
|
750 |
|
char buf[PATH_MAX]; |
|
751 |
|
snprintf(buf, sizeof(buf), "du -sb '%s'", |
|
752 |
|
curr_view->dir_entry[curr_view->list_pos].name); |
|
753 |
|
run_from_fork(out_pipe, 0, buf); |
|
754 |
|
return; |
|
755 |
|
} |
|
756 |
|
else |
|
757 |
|
{ |
|
758 |
|
size_t size; |
|
759 |
|
char buf[128]; |
|
760 |
|
|
|
761 |
|
status_bar_message("Please wait. Calculating directory size..."); |
|
762 |
|
wrefresh(status_bar); |
|
763 |
|
|
|
764 |
|
close(out_pipe[1]); /* Close write end of pipe. */ |
|
765 |
|
read(out_pipe[0], buf, sizeof(buf) - 1); |
|
766 |
|
close(out_pipe[0]); |
|
767 |
|
|
|
768 |
|
size = strtoul(buf, NULL, 10); |
|
769 |
|
tree_set_data(curr_stats.dirsize_cache, |
|
770 |
|
curr_view->dir_entry[curr_view->list_pos].name, (void*)size); |
|
771 |
|
|
|
772 |
|
curr_view->dir_entry[curr_view->list_pos].size = size; |
|
773 |
|
moveto_list_pos(curr_view, curr_view->list_pos); |
|
774 |
|
} |
|
|
738 |
|
moveto_list_pos(curr_view, curr_view->list_pos); |
775 |
739 |
} |
} |
776 |
740 |
|
|
777 |
741 |
/* Jump to top of the list or to specified line. */ |
/* Jump to top of the list or to specified line. */ |