#include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <dir.h> #include <conio.h> #include <all312.h> #include "subor.h" extern short n_dirs,n_files; extern SUBOR subor[MAX_SUBOR]; /********************************************************/ char *nowdir; char *cwd; int pdir[2000]; int now=0,tmp,r; char nme[256]; void scanfls(char name[256],int a,int p,int size){ if(a!=FA_DIREC){ if(n_files<MAX_SUBOR){ sprintf(subor[n_files].filename,"%s/%s",nowdir,name); subor[n_files].size=size; n_files++; } } makaj(); } void scandr(char name[256],int a,int p){ if(r>0) return; if(a==FA_DIREC) if((strcmp(name,".."))&&(strcmp(name,"."))){ if(p==tmp){r=1;strcpy(nme,name);} tmp++; } } void scan_disk_now() { char a=0; struct ffblk f; int done; getcwd(nowdir,256); while(a!=1/*&&!key[KEY_ESC]*/){ tmp=0;r=0; done = findfirst("*.*", &f,FA_DIREC|FA_ARCH|FA_RDONLY|FA_HIDDEN|FA_SYSTEM); while (!done){ scandr(f.ff_name,f.ff_attrib,pdir[now]); done = findnext(&f); } if(r==1){ pdir[now]++;now++;pdir[now]=0;chdir(nme); getcwd(nowdir,256); n_dirs++; } if(now<=0) a=1; if(r==0){ getcwd(nowdir,256); done = findfirst("*.*", &f,FA_ARCH|FA_RDONLY|FA_HIDDEN|FA_SYSTEM); while (!done){ scanfls(f.ff_name,f.ff_attrib,pdir[now],f.ff_fsize); done = findnext(&f); } if(now>0){ now--; chdir(".."); getcwd(nowdir,256); } } } } /********************************************************/ int zober_subory(void) { n_dirs=0; n_files=0; nowdir=malloc(256); cwd=malloc(256); getcwd(cwd,256); scan_disk_now(); chdir(cwd); free(cwd); free(nowdir); }