Re-added recalculating (sub)directories
Этот коммит содержится в:
родитель
b8877be907
Коммит
5790b817f9
@ -295,10 +295,6 @@ int browse_draw() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define toggle(x,y) if(x & y) x -=y; else x |= y
|
||||
#define hideinfo if(stbrowse.flags & BF_INFO) stbrowse.flags -= BF_INFO
|
||||
|
||||
void browse_key_sel(int change) {
|
||||
struct dir *n, *cur, par;
|
||||
int i, max;
|
||||
@ -327,7 +323,12 @@ void browse_key_sel(int change) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define toggle(x,y) if(x & y) x -=y; else x |= y
|
||||
#define hideinfo if(stbrowse.flags & BF_INFO) stbrowse.flags -= BF_INFO
|
||||
|
||||
int browse_key(int ch) {
|
||||
char tmp[PATH_MAX];
|
||||
struct dir *n;
|
||||
|
||||
switch(ch) {
|
||||
@ -403,41 +404,14 @@ int browse_key(int ch) {
|
||||
stbrowse.cur = stbrowse.cur->parent->parent->sub;
|
||||
break;
|
||||
|
||||
/* refresh *
|
||||
/* refresh */
|
||||
case 'r':
|
||||
hideinfo;
|
||||
drawBrowser(0);
|
||||
if((n = showCalc(getpath(bcur, tmp))) != NULL) {
|
||||
* free current items *
|
||||
d = bcur;
|
||||
bcur = bcur->parent;
|
||||
while(d != NULL) {
|
||||
t = d;
|
||||
d = t->next;
|
||||
freedir(t);
|
||||
}
|
||||
|
||||
* update parent dir *
|
||||
bcur->sub = n->sub;
|
||||
bcur->items = n->items;
|
||||
bcur->size = n->size;
|
||||
bcur->asize = n->asize;
|
||||
for(t = bcur->sub; t != NULL; t = t->next)
|
||||
t->parent = bcur;
|
||||
|
||||
* update sizes of parent dirs *
|
||||
for(t = bcur; (t = t->parent) != NULL; ) {
|
||||
t->size += bcur->size;
|
||||
t->asize += bcur->asize;
|
||||
t->items += bcur->items;
|
||||
}
|
||||
|
||||
bcur = bcur->sub;
|
||||
free(n->name);
|
||||
free(n);
|
||||
}
|
||||
stcalc.sterr = ST_BROWSE;
|
||||
stcalc.orig = stbrowse.cur->parent;
|
||||
strcpy(stcalc.cur, getpath(stbrowse.cur, tmp));
|
||||
pstate = ST_CALC;
|
||||
break;
|
||||
*/
|
||||
|
||||
/* and other stuff */
|
||||
case 'q':
|
||||
|
22
src/calc.c
22
src/calc.c
@ -386,15 +386,33 @@ void calc_process() {
|
||||
t->size = fs.st_blocks * S_BLKSIZE;
|
||||
t->asize = fs.st_size;
|
||||
t->flags |= FF_DIR;
|
||||
if(stcalc.orig) {
|
||||
t->parent = stcalc.orig->parent;
|
||||
t->next = stcalc.orig->next;
|
||||
}
|
||||
t->name = (char *) malloc(strlen(tmp)+1);
|
||||
strcpy(t->name, tmp);
|
||||
strcpy(t->name, stcalc.orig ? stcalc.orig->name : tmp);
|
||||
stcalc.parent = t;
|
||||
stcalc.curdev = fs.st_dev;
|
||||
|
||||
/* start calculating */
|
||||
if(!calc_dir(stcalc.parent, tmp) && !stcalc.err) {
|
||||
pstate = ST_BROWSE;
|
||||
stbrowse.cur = stcalc.parent;
|
||||
stbrowse.cur = stcalc.parent->sub;
|
||||
|
||||
/* update references and free original item */
|
||||
if(stcalc.orig) {
|
||||
if(stcalc.orig->parent) {
|
||||
t = stcalc.orig->parent->sub;
|
||||
if(t == stcalc.orig)
|
||||
stcalc.orig->parent->sub = stcalc.parent;
|
||||
else if(t != NULL)
|
||||
for(; t->next!=NULL; t=t->next)
|
||||
if(t->next == stcalc.orig)
|
||||
t->next = stcalc.parent;
|
||||
}
|
||||
freedir(stcalc.orig);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ struct state_calc {
|
||||
char lasterr[PATH_MAX]; /* last unreadable dir/item */
|
||||
char errmsg[128]; /* error message, when err=1 */
|
||||
struct dir *parent; /* parent directory for the calculation */
|
||||
struct dir *orig; /* original directory, when recalculating */
|
||||
dev_t curdev; /* current device we're calculating on */
|
||||
suseconds_t lastupdate; /* time of the last screen update */
|
||||
int anpos; /* position of the animation string */
|
||||
|
@ -141,6 +141,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
pstate = ST_CALC;
|
||||
stcalc.sterr = ST_QUIT;
|
||||
stcalc.orig = NULL;
|
||||
stbrowse.flags = BF_SIZE | BF_DESC;
|
||||
stbrowse.graph = 0;
|
||||
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user