Board index » cppbuilder » IdFTP1->List problem

IdFTP1->List problem


2007-02-14 09:18:09 PM
cppbuilder54
Hi,
I am using Indy 9 with BDS 2006 but have found a problem with the
ftp module when I use IdFTP1->List(SL,"",false); If there is
nothing in the folder it crashes. What can I do to avoid this?
Cheers,
David
 
 

Re:IdFTP1->List problem

"David Ayre" < XXXX@XXXXX.COM >wrote in message
Quote
I am using Indy 9 with BDS 2006 but have found a problem
with the ftp module when I use IdFTP1->List(SL,"",false); If
there is nothing in the folder it crashes.
The server is likely sending back a faulty reply. Look at the "Indy
FTP Response Codes for NLST" discussion in the
"borland.public.delphi.internet.winsock" newsgroup from last night.
Gambit
 

Re:IdFTP1->List problem

"Remy Lebeau \(TeamB\)" < XXXX@XXXXX.COM >wrote:
Quote

"David Ayre" < XXXX@XXXXX.COM >wrote in message
news:45d30c11$ XXXX@XXXXX.COM ...

>I am using Indy 9 with BDS 2006 but have found a problem
>with the ftp module when I use IdFTP1->List(SL,"",false); If
>there is nothing in the folder it crashes.

The server is likely sending back a faulty reply. Look at the "Indy
FTP Response Codes for NLST" discussion in the
"borland.public.delphi.internet.winsock" newsgroup from last night.


Gambit


I've had a look at the NLST discussion but couldn't glean
anything that would help me.
If the server gives the wrong response to IdFTP1->List(SL,"",false);
for an empty folder, how can I detect this and continue,
ignoring the List(), which would then be unnecessary?
David
 

{smallsort}

Re:IdFTP1->List problem

Quote
If the server gives the wrong response to IdFTP1->List(SL,"",false);
for an empty folder, how can I detect this and continue,
Indy uses Exceptions therefore if a bad response is received an exception
should be thrown. That being the case you need to use try/catch to catch
the exceptions and deal with them accordingly.
If an exception isn't thrown, you should check the response code that
is returned and determine your action from there.
Regards,
Tom
 

Re:IdFTP1->List problem

"David Ayre" < XXXX@XXXXX.COM >wrote in message
Quote
I've had a look at the NLST discussion but couldn't glean
anything that would help me.
Then I suggest you use a packet sniffer, such as Ethereal, to find out
exactly what the server is sending.
Gambit
 

Re:IdFTP1->List problem

"Tom" < XXXX@XXXXX.COM >wrote:
Quote
>If the server gives the wrong response to IdFTP1->List(SL,"",false);
>for an empty folder, how can I detect this and continue,

Indy uses Exceptions therefore if a bad response is received an exception
should be thrown. That being the case you need to use try/catch to catch
the exceptions and deal with them accordingly.

If an exception isn't thrown, you should check the response code that
is returned and determine your action from there.

Regards,

Tom

Thanks Tom,
I thought something like that would do it, but I'm not sure how
to set it out. Could you possibly give me a code example.
Cheers,
David
 

Re:IdFTP1->List problem

David,
Without knowing the exact exception that's being thrown, I can only
give you a general try catch example. Once you get the exception
name I would only catch that exception so you can deal with any
others that may show up accordlingly.
try
{
IdFTP1->List(SL, "", false);
}
catch (Exception &e)
{
// This will catch every exception and handle them the same
// way. If you have different exceptions coming up, you need to
// catch them separately by using the proper names.
// IE: catch (EIdSocketError &e) or catch (EIdProtocolReplyError)
// If you need to do something special, put that code here.
// otherwise the error message will disappear. Please remember
// that the error will still be shown if you're using the de{*word*81}.
}
Regards,
Tom
 

Re:IdFTP1->List problem

Thanks Tom,
That seems to have solved the problem.
Cheers,
David
"Tom" < XXXX@XXXXX.COM >wrote:
Quote
David,

Without knowing the exact exception that's being thrown, I can only
give you a general try catch example. Once you get the exception
name I would only catch that exception so you can deal with any
others that may show up accordlingly.

try
{
IdFTP1->List(SL, "", false);
}
catch (Exception &e)
{
// This will catch every exception and handle them the same
// way. If you have different exceptions coming up, you need to
// catch them separately by using the proper names.
// IE: catch (EIdSocketError &e) or catch (EIdProtocolReplyError)

// If you need to do something special, put that code here.
// otherwise the error message will disappear. Please remember
// that the error will still be shown if you're using the de{*word*81}.
}

Regards,

Tom


 

Re:IdFTP1->List problem

"Remy Lebeau \(TeamB\)" < XXXX@XXXXX.COM >wrote:
Quote

"David Ayre" < XXXX@XXXXX.COM >wrote in message
news:45d430c5$ XXXX@XXXXX.COM ...

>I've had a look at the NLST discussion but couldn't glean
>anything that would help me.

Then I suggest you use a packet sniffer, such as Ethereal, to find out
exactly what the server is sending.


Gambit


Thanks Remy,
Ive downloaded that and got it going. In the meantime I just put
the List() into a try/catch and allowed it to ingore the
return when there was an empty folder.
Now I can check the return and make it more specific.
Thanks for your help.
David