---
name: "Net::SFTP::Foreign::Attributes"
section: "3pm"
platform: "linux"
package: "libnet-sftp-foreign-perl"
version: "1.93+dfsg-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Net::SFTP::Foreign::Attributes"
---

# Net::SFTP::Foreign::Attributes(3pm)

File/directory attribute container

## NAME

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

## SYNOPSIS

```
    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;
```

## DESCRIPTION

*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.

## USAGE

- Net::SFTP::Foreign::Attributes-\>**new()**

  Returns a new `"Net::SFTP::Foreign::Attributes"` object.

- Net::SFTP::Foreign::Attributes-\>new\_from\_buffer($buffer)

  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

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.
