Net::FT...irHandle(3)
π Net::FTPServer::RO::DirHandle π
okay bestie, so this is a page from the User Contributed Perl Documentation and it's literally all about the anonymous, read-only FTP server personality π β that's the whole NAME situation. it's the Net::FTPServer::RO::DirHandle module and she is serving directory-handle realness, no cap.
β¨ SYNOPSIS β¨
like, you just pull her in like this:
use Net::FTPServer::RO::DirHandle;
that's it. that's the whole vibe check. periodt. π
πΈ METHODS πΈ
$handle = $dirh->get ($filename);
bestie, this hands you back the file or directory $handle that matches the file $filename inside directory $dirh. and if there's literally no file or subdirectory with that name? it returns undef. gone. ghosted. π«₯
$dirh = $dirh->parent;
gives you the parent directory of the directory $dirh β like calling up your mom directory, iconic. π but heads up: if the directory is already "/", she returns the same directory handle, because / has no parent, she's the final boss, the root, the main character π
$ref = $dirh->list ([$wildcard]);
returns a list of everything inside directory $dirh. the list comes back as a reference to an array of pairs:
[ $filename, $handle ]
and ngl, the list does not include "." or ".." β no crumbs, no leftovers. π
also it's sorted into alphabetical order automatically, so she's organized, she's that girl. β¨
$ref = $dirh->list_status ([$wildcard]);
same energy, but this time it's the contents of directory $dirh plus status info. the list is a reference to an array of triplets:
[ $filename, $handle, $statusref ]
where $statusref is the tuple returned from the "status" method (go peek at Net::FTPServer::Handle, iykyk).
same rules apply: no ".", no "..", and yes, alphabetical order automatically. π
($mode, $perms, $nlink, $user, $group, $size, $time) = $handle->status;
returns the file or directory status. the fields are:
$mode Mode 'd' = directory,
'f' = file,
and others as with
the find(1) -type option.
$perms Permissions Permissions in normal octal numeric format.
$nlink Link count
$user Username In printable format.
$group Group name In printable format.
$size Size File size in bytes.
$time Time Time (usually mtime) in Unix time_t format.
and real talk: in derived classes, some of this status info may well be synthesized, since virtual filesystems will often not contain information in a Unix-like format. so don't be shocked if it's giving β¨customβ¨ energy.
$rv = $handle->move ($dirh, $filename);
moves the current file (or directory) into directory $dirh and renames it $filename. if the operation slays, it returns 0; otherwise it returns -1. π
β οΈ and bestie, listen: underlying filesystems may impose limitations on moves. for example, it may not be possible to move a directory; it may not be possible to move a file to another directory; it may not be possible to move a file across filesystems. so like, temper your expectations π
$rv = $dirh->delete;
deletes the current directory. if the delete command was successful, she returns 0; if there was an error, she returns -1. simple as. π
it is normally only possible to delete a directory if it is empty. no sneaky hidden files allowed, she checks.
$rv = $dirh->mkdir ($name);
creates a subdirectory called $name within the current directory $dirh. baby directory unlocked, congrats π
$file = $dirh->open ($filename, "r"|"w"|"a");
opens or creates a file called $filename in the current directory, opening it for either read, write or append. this function returns a "IO::File" handle object. so you get a whole object back, very demure, very mindful. π§
π AUTHORS π
Richard Jones (rich@annexia.org).
π COPYRIGHT π
Copyright (C) 2000 Biblio@Tech Ltd., Unit 2-3, 50 Carnwath Road, London, SW6 3EG, UK
π SEE ALSO π
and that's a wrap, bestie π«Ά this was Net::FTPServer::RO::DirHandle(3) from perl v5.42.0, dated 2025-07-25 β no cap, go read the source, mwah π
π¦ where this page comes from
- fedora 43: perl-Net-FTPServer 1.125-33.fc43 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms