Skip Menu |

This queue is for tickets about the Tk-RemoteFileSelect CPAN distribution.

Report information
The Basics
Id: 12171
Status: resolved
Priority: 0/
Queue: Tk-RemoteFileSelect

People
Owner: rkies [...] cpan.org
Requestors: DOUGW [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.59
Fixed in: (no value)



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; }
[guest - Wed Apr 6 16:07:50 2005]: Cleaned up patch.
--- RemoteFileSelect.pm.old1 Thu Mar 31 13:33:21 2005 +++ RemoteFileSelect.pm Wed Apr 06 13:29:19 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,6 +195,19 @@ $transcript ); if( defined $ftp ) { + 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." ); + } + } + } my $dir = $ftp -> pwd(); $cw -> remoteDirectory( $dir ); } @@ -501,6 +523,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 +620,7 @@ return; } if( ! $ftp -> cwd( "$current/$dir" ) ) { - $cw -> error( "Cannot cwd to $current/$dir." ); + $cw -> Error( "Cannot cwd to $current/$dir." ); $cw -> rereadRemote; return; }
From: dougw [...] cpan.org
Correction to above patch: change "if (defined $remote_dir)" to "if (defined $remote_dir and $remote_dir ne '')" since tk parameters appear to be always defined even if they are not used.
[guest - Wed Apr 6 16:07:50 2005]: Show quoted text
> 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.
Patch applied.