Sept
![](http://forum.ru-board.com/board/avatars/p43.gif)
Junior Member | Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору извините, что перебиваю ваш разговор, но мне нужна помошь (опять же) Код: #include <stdio.h> #include <stdlib.h> #include <vcl.h> #include <dialogs.hpp> void ListFiles(AnsiString path, TStrings* List) { TSearchRec sr; if (FindFirst(path+"*.*", faAnyFile, sr) == 0) { do { if (sr.Attr & faDirectory) { if (sr.Name!=".") if (sr.Name!="..") { ListFiles(path+sr.Name+"\\",List);// Рекурсивный вызов } } else List->Add(path+sr.Name); } while (FindNext(sr) == 0); FindClose(sr); } Application->ProcessMessages(); } //******************************************* void xorer(String filename, String keyname) { FILE *fio,*fo; int c, max_value; register int i=0; char xorerstring[50000]; if ((fio=fopen(keyname.c_str(),"rb+"))!=NULL) while ((c=getc(fio))!=EOF) xorerstring[i++]=c ; fclose(fio) ; max_value=i-1 ; i=0 ; if ((fio=fopen(filename.c_str(),"rb+"))!=NULL) { fo=fopen("dopfile","wb+"); while ((c=getc(fio))!=EOF) { if (i>=max_value) i=0; c^= (xorerstring[i++]); putc(c,fo); } fclose(fio); fio=fopen(filename.c_str(),"wb+"); fclose(fo); fo=fopen("dopfile","rb"); while ((c=getc(fo))!=EOF) putc(c,fio); fclose(fio); fclose(fo); } DeleteFile("dopfile") ; } //******************************************* int main(int argc, char* argv[]) { char *dir =argv[1] ; //char *out =argv[2] ; int v=0, c, i ; FILE *file[8], *dop ; TStringList *L_1 = new TStringList ; TStringList *L_2 = new TStringList ; int mass[12000] ; String names[12000] ; String str =(String)dir+".ESS"; if(fopen(str.c_str(),"rb+")==NULL) { ListFiles((String)dir+"\\",L_1) ; file[7]=fopen(str.c_str(),"wb+") ; for(i=0;i<L_1->Count;i++) { file[0]=fopen((*L_1)[i].c_str(),"rb+") ; v=0 ; while ((c=getc(file[0]))!=EOF) { v++ ; putc(c,file[7]) ; } mass[i]=v ; names[i]=(*L_1)[i] ; fclose(file[0]) ; } fclose(file[7]) ; L_1->Clear() ; for(int g=0;g<i;g++) L_1->Add(mass[g]) ;L_1->SaveToFile((String)str+".mass") ; L_1->Clear() ; for(int g=0;g<i;g++) L_1->Add(names[g]) ;L_1->SaveToFile((String)str+".names") ; xorer(str+".names", str+".mass") ; xorer(str, str+".names") ; } else { xorer(str, str+".names") ; xorer(str+".names", str+".mass") ; file[0]=fopen(str.c_str(),"rb+") ; L_1->LoadFromFile((String)str+".names") ; L_2->LoadFromFile((String)str+".mass") ; int ind=12000 ; for(int index=0;index<L_1->Count;index++) { String str=(*L_1)[index].SubString(1,LastDelimiter("\\",(*L_1)[index])) ; CreateDir(dir) ; while(str!=dir) { names[ind]=str ; ind-- ; str=str.SubString(1,LastDelimiter("\\",str)-1) ; } } for(int index=ind;index<12000;index++) CreateDir(names[index]) ; for(int index=0;index<L_1->Count;index++) { file[1]=fopen((*L_1)[index].c_str(),"wb+") ; int a=(*L_2)[index].ToInt() ; for(int index_2=0;index_2<a;index_2++) { c=getc(file[0]) ; putc(c,file[1]) ; } fclose(file[1]) ; } } return 0; } //******************************************* | воть... стиль некудышный. Помогите сделать так, чтоб паковал файлы, имеющие в названии пробел, ато он их игнорирует. ps запускать прогу с батника с параметром - имя директории, в которой хранятся файлы для упаковки |