BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TIdFTP equivalent to ForceDirectories?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
Kevin Killion
Guest





PostPosted: Fri Sep 08, 2006 3:29 am    Post subject: TIdFTP equivalent to ForceDirectories? Reply with quote



Is there any way in TIdFTP to guarantee that a path exists, akin to
Delphi's ForceDirectories function?

Example:
Given a path "clients/acme/2004/june"
Create "clients", "acme", "2004", and "june" as needed

I tried MakeDir, but it doesn't seem to like accepting a whole path.

I could roll-my-own equivalent by testing directories one after another
to see if they exist, and calling TIdFTP.MakeDir one at a time if they
don't. But then again, I don't see any obvious equivalent to Delphi's
"DirectoryExists" either.

Suggestions?

Thanks!

Kevin Killion
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Sep 08, 2006 4:27 am    Post subject: Re: TIdFTP equivalent to ForceDirectories? Reply with quote



"Kevin Killion" <kevinNOSPAM (AT) shsmedia (DOT) com> wrote in message
news:kevinNOSPAM-11843A.17292107092006 (AT) newsgroups (DOT) borland.com...

Quote:
Is there any way in TIdFTP to guarantee that a path exists,
akin to Delphi's ForceDirectories function?

There is nothing in the FTP protocol for that. You will have to manually do
what ForceDirectories() does internally - attempt to create a folder and
then check if the server reports whether it already exists, repeating
recursively for each subfolder as needed.

Quote:
Example:
Given a path "clients/acme/2004/june"
Create "clients", "acme", "2004", and "june" as needed

You have to do that yourself one at a time. Create the "clients" folder,
then change to it, then create the "acme" folder, then change to it, and so
on.

Quote:
I tried MakeDir, but it doesn't seem to like accepting a whole path.

You can't create whole paths in a single operation. You have to do it one
at a time. ForceDirectories() does the same thing internally.

Quote:
I could roll-my-own equivalent by testing directories one after
another to see if they exist, and calling TIdFTP.MakeDir one at
a time if they don't.

That is exactly what you have to do.

Quote:
But then again, I don't see any obvious equivalent to Delphi's
"DirectoryExists" either.

MakeDir() will throw an exception that you can catch if the folder already
exists. The FTP protocol requires the server to report an error when a
client tries to create an existing folder.

Alternatively, perform a directory listing on the parent folder, and see
whether the desired subfolder is contained in the listing.


Gambit
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.