|
Lines 259-267
sub change_directory {
Link Here
|
| 259 |
|
259 |
|
| 260 |
=head3 list_files |
260 |
=head3 list_files |
| 261 |
|
261 |
|
| 262 |
my @files = $server->list_files; |
262 |
my $files = $server->list_files; |
| 263 |
|
263 |
|
| 264 |
Returns an array of filenames found in the current directory. |
264 |
Returns an array reference of hashrefs with file information found in the current directory. |
|
|
265 |
Each hashref contains: filename, longname, size, perms, mtime. |
| 265 |
|
266 |
|
| 266 |
=cut |
267 |
=cut |
| 267 |
|
268 |
|
|
Lines 302-310
sub list_files {
Link Here
|
| 302 |
|
303 |
|
| 303 |
my @files; |
304 |
my @files; |
| 304 |
while ( defined( my $file = $dir_handle->read ) ) { |
305 |
while ( defined( my $file = $dir_handle->read ) ) { |
| 305 |
next if $file =~ /^\.\.?$/; # Skip . and .. |
306 |
next if $file =~ /^\.\.?$/; # Skip . and .. |
| 306 |
next unless -f File::Spec->catfile( $directory, $file ); # Only files |
307 |
my $full_path = File::Spec->catfile( $directory, $file ); |
| 307 |
push @files, $file; |
308 |
next unless -f $full_path; # Only files |
|
|
309 |
|
| 310 |
# Get file stats for consistency with SFTP format |
| 311 |
my @stat = stat($full_path); |
| 312 |
my $size = $stat[7] || 0; |
| 313 |
my $mtime = $stat[9] || 0; |
| 314 |
my $mode = $stat[2] || 0; |
| 315 |
|
| 316 |
# Create permissions string (simplified) |
| 317 |
my $perms = sprintf( "%04o", $mode & oct('07777') ); |
| 318 |
|
| 319 |
push @files, { |
| 320 |
filename => $file, |
| 321 |
longname => sprintf( "%s %8d %s %s", $perms, $size, scalar( localtime($mtime) ), $file ), |
| 322 |
size => $size, |
| 323 |
perms => $perms, |
| 324 |
mtime => $mtime |
| 325 |
}; |
| 308 |
} |
326 |
} |
| 309 |
$dir_handle->close; |
327 |
$dir_handle->close; |
| 310 |
|
328 |
|