> Does someone have an example in Delphi of the use of virtual 
> directories using the FtpServer component 

I have two arrays with the virtual and physical names:
VDirs: WideStringArray ;
PDirs: WideStringArray ;

which is filled with real paths:
VDir1=d:\websites\logfiles
PDir1=d:\logs

so if the root is websites and the path logfiles, it changes to d:\logs.
Then in event FtpServerAlterDirectory, translate the paths both ways: 

if ClientSoc.TotVirDir = 0 then exit ;
for I := 0 to ClientSoc.TotVirDir - 1 do
begin
    if (FileName <> '?') then 
// ? is used in FormatResponsePath to get original path
    begin
     // translate virtual to phyiscal directory
       if Pos (ClientSoc.VDirs [I], Directory) = 1 then
       begin
           NewFileName := ClientSoc.PDirs [I] + Copy (Directory,
                Length (ClientSoc.VDirs [I]) + 1, 999) + FileName ;
           exit ;
       end;
    end
    else
    begin
    // translate physical to virtual directory
       if (Pos (ClientSoc.PDirs [I], Directory) = 1) then
       begin
          NewFileName := ClientSoc.VDirs [I] + Copy (Directory,
                Length (ClientSoc.PDirs [I]) + 1, 999) ;
          exit ;
       end;
    end;
 end;

You also need to override BuildDirList to check for virtual directories
at root level and build a virtual directory listing from the correct
physical path, but that's too much code for this list.  

Angus

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to