Net::S...ibutes(3pm)

πŸ“¦
version 1.93 Β· 6 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Net::SFTP::Foreign::Attributes πŸ’–

okay bestie, sit down, hydrate, because we're talking about the file/directory attribute container for Net::SFTP::Foreign β€” that's the whole vibe of this page from the User Contributed Perl Documentation collection. It's literally just a lil box that holds all the metadata about a file or directory on the remote side. πŸŽ€


✨ SYNOPSIS ✨

here's the whole thing in action, no edits, no notes:

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;

see how cute that is? build one, fill it in, or grab one straight off stat and read the fields out. πŸ’…


🌸 DESCRIPTION 🌸

Net::SFTP::Foreign::Attributes is the little container that encapsulates file/directory attributes for Net::SFTP::Foreign. But wait, there's more β€” it also ships serialization and deserialization</> methods so you can encode/decode all those attributes into Net::SFTP::Foreign::Buffer objects. it's giving translator energy. πŸ¦‹


πŸŽ€ USAGE πŸŽ€

  • Net::SFTP::Foreign::Attributes->new() β€” hands you a brand new Net::SFTP::Foreign::Attributes object, fresh out the box, no notes. ✨
  • Net::SFTP::Foreign::Attributes->new_from_buffer($buffer) β€” makes a new attributes object and populates it with the info it read out of $buffer.
  • $attrs->as_buffer β€” serializes the Attributes object $attrs into a buffer object. packing it up, sending it off. πŸ“¦
  • $attrs->flags β€” returns the value of the flags field.
  • $attrs->size β€” returns the value of the size field, or undef if it's not set.
  • $attrs->uid β€” returns the value of the uid field, or undef if it's not set.
  • $attrs->gid β€” returns the value of the gid field, or undef if it's not set.
  • $attrs->perm β€” returns the value of the permissions field, or undef if it's not set.

also, go check out "stat" in perlfunc for the tea on how to process that returned value with the Fcntl module. iykyk.

for instance, this here 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's not set.
  • $attrs->mtime β€” returns the value of the mtime field, or undef if it's not set.
  • %extended = $attr->extended β€” returns the vendor-dependent extended attributes. spooky vendor-specific lore. πŸ‘‘
  • $attrs->set_size($size) β€” sets the value of the size field. but if $size is undef, it removes the field instead. either way, the flags field gets 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're undefined values. the flags field is adjusted.
okay important: this pair of fields can not be set separately, because they share the same bit on the flags field. so it's both or neither, bestie. no splitting them up. πŸ’€
  • $attr->set_amtime($atime, $mtime) β€” sets the values of the atime and mtime fields, or removes them if they're 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 onto the list of vendor-dependent extended attributes. stacking them up. 🫢

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.


and that's the whole page, bestie! 🌈 this one came to you courtesy of perl v5.32.0, dated 2021-01-23, and it's the Net::SFTP::Foreign::Attributes page from the User Contributed Perl Documentation set. go forth and read your remote file metadata, you absolute icon. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from