Net::FT...irHandle(3)

πŸ“¦
version 1.125 Β· 2 versions
, in fedora 43

πŸ’– 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. 🌈

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 (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