Changeset 9215 for trunk/Padre/lib/Padre/File/FTP.pm
- Timestamp:
- 11/14/09 04:07:33 (2 years ago)
- File:
-
- 1 edited
-
trunk/Padre/lib/Padre/File/FTP.pm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Padre/lib/Padre/File/FTP.pm
r9177 r9215 16 16 my $url = shift; 17 17 18 my $config = Padre->ide->config;19 20 18 # Create myself 21 19 my $self = bless { filename => $url }, $class; 20 21 # Using the config is optional, tests and other usages should run without 22 my $config = eval { return Padre->ide->config; }; 23 if (defined($config)) { 24 $self->{_timeout} = $config->file_ftp_timeout; 25 $self->{_passive} = $config->file_ftp_passive; 26 } else { 27 # Use defaults if we have no config 28 $self->{_timeout} = 60; 29 $self->{_passive} = 1; 30 } 22 31 23 32 # Don't add a new overall-dependency to Padre: … … 72 81 Host => $self->{_host}, 73 82 Port => $self->{_port}, 74 Timeout => $ config->file_ftp_timeout,75 Passive => $ config->file_ftp_passive,83 Timeout => $self->{_timeout}, 84 Passive => $self->{_passive}, 76 85 77 86 # Debug => 3, # Enable for FTP-debugging to STDERR … … 135 144 my $self = shift; 136 145 return if !defined( $self->{_ftp} ); 137 return $self->size ? 1 : 0; 146 147 # Cache basename value 148 my $basename = $self->basename; 149 150 for ($self->{_ftp}->ls($self->{_file})) { 151 return 1 if $_ eq $self->{_file}; 152 return 1 if $_ eq $basename; 153 } 154 155 # Fallback if ->ls didn't help. A file heaving a size should exist. 156 return 1 if $self->size; 157 158 return 0; 138 159 } 139 160 … … 147 168 } 148 169 170 # This method should return the dirname to be used inside Padre, not the one 171 # used on the FTP-server. 149 172 sub dirname { 150 173 my $self = shift; 151 174 152 my $dir = $self->{ _file};175 my $dir = $self->{filename}; 153 176 $dir =~ s/\/[^\/]*$//; 154 177 … … 194 217 } 195 218 219 ############################################################################### 220 ### Internal FTP helper functions 221 222 sub _ftp_dirname { 223 my $self = shift; 224 225 my $dir = $self->{_file}; 226 $dir =~ s/\/[^\/]*$//; 227 228 return $dir; 229 } 230 231 196 232 1; 197 233
Note: See TracChangeset
for help on using the changeset viewer.
