views:

67

answers:

2

How to identify whether the item of a directory is a file or a directory using Net::SFTP or ruby code?

+5  A: 

The do_stat method seems like it could get you that information. See also the documentation for Net::SFTP::Attributes and perldoc -f stat.

innaM
+4  A: 

To illustrate the use of Manni's recommendation:

use Fcntl(:mode);

my $permissions  = $sftp->do_stat($path)->perm();
my $is_directory = S_ISDIR($permissions);
Adam Bellaire