Subject: | Specify default remote directories |
Patch creates -remotedirectory option which allows specifying initial directory when logging into remote hosts. Also fixes call to Error when remote cwd does not work.
--- RemoteFileSelect.pm.old1 Thu Mar 31 13:33:21 2005
+++ RemoteFileSelect.pm Wed Apr 06 13:02:52 2005
@@ -31,6 +31,15 @@
Specifies the initial directory to start in.
+=item Name: B<remotedirectory>
+
+=item Switch: B<-remotedirectory>
+
+Specifies the initial directory to start in after connecting to remote hosts.
+Value may be a directory or a hashref which specifies host and directory, e.g.
+
+ -remotedirectory => { host1 => /some/directory, host2 => /other/directory }
+
=item Name: B<ftpvariable>
=item Switch: B<-ftpvariable>
@@ -186,7 +195,22 @@
$transcript );
if( defined $ftp ) {
- my $dir = $ftp -> pwd();
+ my $dir;
+ my $remote_dir = $cw -> cget("-remotedirectory");
+ if (defined $remote_dir) {
+ my $rdir = ref($remote_dir)
+ ? exists($remote_dir->{$hostid})
+ ? $remote_dir->{$hostid}
+ : undef
+ : $remote_dir;
+ if (defined $rdir) {
+ if( ! $ftp -> cwd( $rdir ) ) {
+ $cw -> Error( "Cannot cwd to $rdir." );
+ $dir = '';
+ }
+ }
+ }
+ $dir = $ftp -> pwd() unless $dir;
$cw -> remoteDirectory( $dir );
}
}
@@ -501,6 +525,7 @@
-ftpvariable => ['PASSIVE', undef, undef, '' ],
-useridvariable => ['PASSIVE', undef, undef, '' ],
-passwordvariable => ['PASSIVE', undef, undef, '' ],
+ -remotedirectory => ['PASSIVE', undef, undef, '' ],
DEFAULT => [ 'file_list' ],
);
$w->Delegates(DEFAULT => 'file_list');
@@ -597,7 +622,7 @@
return;
}
if( ! $ftp -> cwd( "$current/$dir" ) ) {
- $cw -> error( "Cannot cwd to $current/$dir." );
+ $cw -> Error( "Cannot cwd to $current/$dir." );
$cw -> rereadRemote;
return;
}