DOKK / manpages / debian 12 / libnet-sftp-foreign-perl / Net::SFTP::Foreign::Attributes.3pm.en
Net::SFTP::Foreign::Attributes(3pm) User Contributed Perl Documentation Net::SFTP::Foreign::Attributes(3pm)

Net::SFTP::Foreign::Attributes - File/directory attribute container

    use Net::SFTP::Foreign;
    my $a1 = Net::SFTP::Foreign::Attributes->new();
    $a1->set_size($size);
    $a1->set_ugid($uid, $gid);
    my $a2 = $sftp->stat($file)
        or die "remote stat command failed: ".$sftp->status;
    my $size = $a2->size;
    my $mtime = $a2->mtime;

Net::SFTP::Foreign::Attributes encapsulates file/directory attributes for Net::SFTP::Foreign. It also provides serialization and deserialization methods to encode/decode attributes into Net::SFTP::Foreign::Buffer objects.

Returns a new "Net::SFTP::Foreign::Attributes" object.
Creates a new attributes object and populates it with information read from $buffer.
$attrs->as_buffer
Serializes the Attributes object $attrs into a buffer object.
$attrs->flags
returns the value of the flags field.
$attrs->size
returns the values of the size field or undef if it is not set.
$attrs->uid
returns the value of the uid field or undef if it is not set.
$attrs->gid
returns the value of the gid field or undef if it is not set.
$attrs->perm
returns the value of the permissions field or undef if it is not set.

See also "stat" in perlfunc for instructions on how to process the returned value with the Fcntl module.

For instance, the following code checks if some attributes object corresponds to a directory:

  use Fcntl qw(S_ISDIR);
  ...
  if (S_ISDIR($attr->perm)) {
    # it is a directory!
  }
    
$attrs->atime
returns the value of the atime field or undef if it is not set.
$attrs->mtime
returns the value of the mtime field or undef if it is not set.
%extended = $attr->extended
returns the vendor-dependent extended attributes
$attrs->set_size($size)
sets the value of the size field, or if $size is undef removes the field. The flags field is adjusted accordingly.
$attrs->set_perm($perm)
sets the value of the permissions field or removes it if the value is undefined. The flags field is also adjusted.
$attr->set_ugid($uid, $gid)
sets the values of the uid and gid fields, or removes them if they are undefined values. The flags field is adjusted.

This pair of fields can not be set separately because they share the same bit on the flags field and so both have to be set or not.

$attr->set_amtime($atime, $mtime)
sets the values of the atime and mtime fields or remove them if they are undefined values. The flags field is also adjusted.
$attr->set_extended(%extended)
sets the vendor-dependent extended attributes
$attr->append_extended(%more_extended)
adds more pairs to the list of vendor-dependent extended attributes

Copyright (c) 2006-2008 Salvador Fandiño.

All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

2021-01-23 perl v5.32.0