Net::S...ibutes(3pm)
π 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 newNet::SFTP::Foreign::Attributesobject, 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$attrsinto 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, orundefif it's not set.$attrs->uidβ returns the value of the uid field, orundefif it's not set.$attrs->gidβ returns the value of the gid field, orundefif it's not set.$attrs->permβ returns the value of the permissions field, orundefif 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, orundefif it's not set.$attrs->mtimeβ returns the value of the mtime field, orundefif 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$sizeisundef, 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 π
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
- debian bookworm: libnet-sftp-foreign-perl 1.93+dfsg-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libnet-sftp-foreign-perl 1.93+dfsg-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libnet-sftp-foreign-perl 1.93+dfsg-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libnet-sftp-foreign-perl 1.93+dfsg-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libnet-sftp-foreign-perl 1.93+dfsg-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-sftp-foreign-perl 1.93+dfsg-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms