Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Сети";
Текущий архив: 2004.03.14;
Скачать: [xml.tar.bz2];

Вниз

Вопрос: Ошибка при рекурсивном переборе файлов на фтп...   Найти похожие ветки 

 
St!ff   (2004-01-04 05:44) [0]

Код:
//--------------------

function arr2string(a:array of char):string;
var
i:integer;
s:string;
begin
i:=0;
while (a[i]<>#0) do
begin
s:=s+a[i];
i:=i+1;
end;
result:=s;
end;

function GetCurrentDirectory(FFTPHandle:HINTERNET): string;
var
Len: DWord;
S: string;
begin
Len := 0;
ftpGetCurrentDirectory(FFTPHandle, PChar(S), Len);
SetLength(S, Len);
ftpGetCurrentDirectory(FFTPHandle, PChar(S), Len);
Result := S;
end;

procedure ListCurrentDirectory(dir:string;ip:string;num,ipnum:integer);
var
dir1,s,fn:string;
hSearch: HINTERNET;
findData: WIN32_FIND_DATA;
hConnect,handle:hInternet;
hOpen:HINTERNET;
lst:tstringlist;
i:integer;
zapros:string;
nextfile:bool;
begin
nextfile:=false;
lst:=tstringlist.Create;
with form1.ListView1 do
begin
form1.ListView1.Items[ipnum].SubItems[1]:=dir;
form1.ListView1.Items[ipnum].SubItems[0]:="Listing";
end;

if dir="/" then
begin
Add2Log(" Поток "+inttostr(num)+" Соединяемся с ip "+ip,2);
showmessage("First");
end;

if hConnect=nil then
begin
hOpen := InternetOpen("St!ff""sSearchMahine",LOCAL_INTERNET_ACCESS,nil,0,0);
hConnect := InternetConnect(hOpen, pchar(ip) ,INTERNET_INVALID_PORT_NUMBER, "anonymous","guest",INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE ,0);
Add2Log("Error InternetConnect "+errcode,1);
end;

Add2Log("hConnect dir="+dir,2);
handle := hConnect;
dir1:=string2string(GetCurrentDirectory(handle ));
S := (dir);
if S <> "" then
if not FtpSetCurrentDirectory(Handle, PChar(S)) then Add2Log("Error FtpSetCurrentDirectory "+errcode,1);

hSearch := FtpFindFirstFile(handle,nil,findData,0,0);
Add2Log(dir+"/"+string2string(findData.cFileName),1);

if hSearch = nil then
begin
// Something has gone wrong!
// Perhaps we"ve been disconnected?
Add2Log(" Поток "+inttostr(num)+" Something has gone wrong! ip = "+ip+" "+errcode,1);
form1.ListView1.Items[ipnum].SubItems[0]:="Error";
form1.ListView1.Items[ipnum].SubItems[1]:=errcode;
Sost[ipnum]:="0";

end
else
begin
//--------------------------------
// Loop reading directory entries.
//--------------------------------
Add2Log("Loop",2);
repeat
fn:=arr2string(findData.cFileName);
if (fn <>".") and (fn<>"..")then
begin
application.ProcessMessages;
if (findData.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY)then
begin
s:=string2string(GetCurrentDirectory(handle)) ;
dircount:=dircount+1;
if s="/" then
begin
zapros:=("INSERT INTO ip_files (file) VALUES(""+ip+s+fn + "/")");
lst.Add(s+fn)
end
else
begin
zapros:=("INSERT INTO ip_files (file) VALUES(""+ip+s+ "/"+fn + "/")"); lst.Add(s+ "/"+fn);
end;
end
else
begin
s:=string2string(GetCurrentDirectory(handle));
filecount:=filecount +1;
form1.Label1.Caption:=inttostr(filecount);
if s="/" then
begin
zapros:=("INSERT INTO ip_files (file) VALUES(""+ip+s+fn+"")");
end
else
begin
zapros:=("INSERT INTO ip_files (file) VALUES(""+ip+s+"/"+fn+"")");
end;
end;
end;

{form1.ZSQLProcessor1.Script.Clear;
form1.ZSQLProcessor1.Script.Add(zapros);
form1.ZSQLProcessor1.Execute;
form1.ZSQLProcessor1.Script.Clear;}
nextfile:= InternetFindNextFile(hSearch,@findData);
Add2Log(dir+"/"+string2string(findData.cFileName)+" "+floattostr(findData.nFileSizeLow)+"errcode "+errcode,1);

until not nextfile;
InternetCloseHandle(hSearch);
InternetCloseHandle(hOpen);
InternetCloseHandle(hConnect);

Add2Log("ListCurrentDirectory",2);

for i:=0 to lst.Count-1 do
begin
ListCurrentDirectory(lst.Strings[i],ip,num,ipnum);
end;

lst.Clear;
lst.Destroy;

end;

if dir="" then
begin
form1.ListView1.Items[ipnum].SubItems[0]:=Sost[ipnum];
Add2Log(" Поток "+inttostr(num)+" Индексация "+ip+" закончена",2);
end;

end;

procedure Add2Log(S:string;level:integer);
var
ListItem: TListItem;
f:text;//file;
s1:string;
StrList:TStringList;
outfile: TextFile;
Begin

AssignFile(outfile, "c:\outfile.txt");
Append(outfile);
writeln(outfile,"["+FormatDateTime("hh.mm.ss",now)+"]"+ S);
CloseFile(outfile);

with form1.ListView2 do
begin

ViewStyle := vsReport;
ListItem := Items.Add;
ListItem.Caption :="["+FormatDateTime("hh.mm.ss",now)+"]"+ S;

end;

itm:=form1.ListView2.Items.Count-1;
itm:=form1.ListView2.Items.Count-1;
form1.ListView1.Perform(LVM_ENSUREVISIBLE, itm, 0);
ListView_EnsureVisible(form1.ListView1.Handle, itm, false);
{если подскажите как это прокрутить вниз буду очень благодарен}
end;

//---------------------------------------------


 
St!ff   (2004-01-04 05:44) [1]

кусок лога

//---------------------------------------------
[05.10.11]Error InternetConnect
[05.10.11]hConnect dir=
[05.10.12]/!nstruction.txt
[05.10.12]Loop
[05.10.12]/. 0 errcode
[05.10.12]/.. 0 errcode
[05.10.12]/4c4d-dntdt.jpg 108936 errcode
[05.10.12]/AquariumV11.exe 1052344 errcode
[05.10.12]/cd-client-4_4_0-en.exe 281018 errcode
[05.10.12]/cd-client-4_7_0-en.exe 293349 errcode
[05.10.12]/freesco-026 0 errcode
[05.10.12]/freesco-030 0 errcode
[05.10.12]/ftp.jpg 67426 errcode
[05.10.12]/games 0 errcode
[05.10.12]/ichat121b4.exe 96714 errcode
[05.10.12]/ichat121b6.exe 1127747 errcode
[05.10.12]/key.txt 22 errcode
[05.10.12]/mirc603.exe 1216000 errcode
[05.10.12]/picture 0 errcode
[05.10.12]/pub 0 errcode
[05.10.12]/radmin21.exe 1382683 errcode
[05.10.12]/regcode.txt 88 errcode
[05.10.12]/slave 0 errcode
[05.10.12]/soft 0 errcode
[05.10.12]/windows 0 errcode
[05.10.12]/windows 0 errcode ERROR_NO_MORE_FILES
[05.10.12]ListCurrentDirectory
[05.10.12]Error InternetConnect
[05.10.12]hConnect dir=/freesco-026
[05.10.12]/freesco-026/.
[05.10.12]Loop
[05.10.12]/freesco-026/.. 0 errcode
[05.10.12]/freesco-026/date-uix.tgz 9204 errcode
[05.10.12]/freesco-026/date-w32.zip 29421 errcode
[05.10.12]/freesco-026/fast_fd.bat 341 errcode

<skip>

[05.26.00]/soft/trash/HACK/Декомпиляторы/windows 0 errcode
[05.26.00]/soft/trash/HACK/Декомпиляторы/windows 0 errcode ERROR_NO_MORE_FILES
[05.26.00]ListCurrentDirectory
[05.26.00]Error InternetConnect
[05.26.00]hConnect dir=/freesco-026
[05.26.00]/freesco-026/.
[05.26.00]Loop
[05.26.00]/freesco-026/.. 0 errcode
[05.26.00]/freesco-026/date-uix.tgz 9204 errcode
[05.26.00]/freesco-026/date-w32.zip 29421 errcode

//-------------------------------------------------

Суть этого всего: прога индексирует фтп (ip) и должен добавить список файлов в базу. При индексации моего фтм (мне доступ везде разрешен) все индексируется нормально. При индексации другого фтп когда очередь доходит до папки /soft/trash/HACK/Декомпиляторы/windows програма перескакивает почти "вначало" фтп, в ту папку которую она прошла (/freesco-026) При попытке открытия папки (/soft/trash/HACK/Декомпиляторы/) в IE выдается сообщение "В ходе открытия папки на FTP-сервере произошла ошибка. Убедитесь, что у вас есть разрешение открывать эту папку.
Подробности:
550 /soft/trash/HACK/Декомпилоры: No such file or directory.
"

Вот. Памагите плз...


 
St!ff   (2004-01-04 05:49) [2]

Т.е. как это отловиь?Как обойити директорию в которуб нельзя войти?


 
St!ff   (2004-01-05 03:20) [3]

Мастера... памагите...
Ссылку хоть дайте что-ли...



Страницы: 1 вся ветка

Форум: "Сети";
Текущий архив: 2004.03.14;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.47 MB
Время: 0.014 c
1-43475
Sand
2004-02-29 15:50
2004.03.14
Object Inspektor не сохраняет установки для моей компоненты


14-43841
Igor_thief
2004-02-21 17:39
2004.03.14
Админам


3-43390
uu
2004-02-13 20:30
2004.03.14
CREATE GENERATOR


7-43913
Ozone
2003-12-18 10:22
2004.03.14
Web-камера


3-43249
Belkova
2004-02-13 12:03
2004.03.14
DBGrid





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский