Plain(3pm)

πŸ“¦
version 0.10 Β· 2 versions
  • 0.10 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.10 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

okay bestie, say hi to Filesys::Virtual::Plain β€” it's A Plain virtual filesystem. yes, that's the whole name, it's giving minimal and we respect it ✨

This page lives in the User Contributed Perl Documentation section, and it's the Plain(3pm) girlie. πŸŽ€


🌸 SYNOPSIS 🌸

here's the vibe, copy-paste it exactly, no cap:

use Filesys::Virtual::Plain;

my $fs = Filesys::Virtual::Plain->new();

$fs->login('xantus', 'supersekret');

print foreach ($fs->list('/'));

like… make the object, log in, print everything in /. slay. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

This module is used by other modules to provide a pluggable filesystem. it's the behind-the-scenes bestie, the main character who lets everyone else shine. 🫢


πŸŽ€ CONSTRUCTOR πŸŽ€

✨ new()

You can pass the initial cwd, root_path, and home_path as a hash. that's it, that's the tea πŸ’œ


πŸ‘‘ METHODS πŸ‘‘

🌈 login($username, $password, $become)

Logs in a user. Returns 0 on failure. 🚨

If $username is 'anonymous' then it will try to login as 'ftp' with no password β€” sneaky lil anonymous era, we love it.

If $become is defined then it will try to change ownership of the process to the uid/gid of the logged in user.

⚠️ BEWARE of the consequences of using $become. like, actually beware. this is not a drill bestie 😭

login() also sets the uid, gid, home, gids, home_path, and chdir to the users'. so it does a LOT. multitasking queen πŸ‘‘

🌸 cwd

Gets or sets the current directory, assumes / if blank. This is used in conjunction with the root_path for file operations. No actual change directory takes place β€” it's all vibes, nothing physical. 🧚

πŸ’œ root_path($path)

Get or set the root path. All file paths are off this and cwd. For example:

$self->root_path('/home/ftp');
$self->cwd('/test');
$self->size('testfile.txt');

The size command would get the size for file /home/ftp/test/testfile.txt not /test/testfile.txt. iykyk β€” the paths stack, okay?? ✨

πŸ¦‹ chmod($mode,$file)

chmod's a file. short king of a method, does exactly what it says πŸ’…

⭐ modtime($file)

Gets the modification time of a file in YYYYMMDDHHMMSS format. that format. memorize it. it's iconic. πŸ“…

πŸ“ size($file)

Gets the size of a file in bytes. numbers don't lie bestie πŸ’–

🌈 delete($file)

Deletes a file, returns 1 or 0 on success or failure. binary queen, she doesn't do in-between πŸ’€

🧚 chdir($dir)

Changes the cwd to a new path from root_path. Returns undef on failure or the new path on success. so if you get undef, that's your sign, bestie 🫢

πŸ’– mkdir($dir, $mode)

Creats a directory with $mode (defaults to 0755) and chown()'s the directory with the uid and gid. The return value is from mkdir().

note: yes, it really says "Creats" in the original. we keep the lore. πŸ™ˆ

🌸 rmdir($dir)

Deletes a directory or file if -d test fails. Returns 1 on success or 0 on failure. so it's a little bit of a both-jobs icon πŸ‘‘

πŸ’œ list($dir)

Returns an array of the files in a directory. just the names, quick and cute ✨

πŸŽ€ list_details($dir)

Returns an array of the files in ls format. the full glam version, all the deets πŸ’…

⭐ stat($file)

Does a normal stat() on a file or directory. no notes. 🌈

πŸ¦‹ test($test,$file)

Perform a perl type test on a file and returns the results.

For example to perform a -d on a directory:

$self->test('d','/testdir');

See filetests in perlfunc (commandline: perldoc perlfunc). go read it, i'll wait 🫢

πŸ“ open_read($file,[params])

Opens a file with IO::File. Params are passed to open() of IO::File. It returns the file handle on success or undef on failure. This could be technically be used for any sort of open operation. See IO::File's open method. versatile legend ✨

πŸ’– close_read($fh)

Performs a $fh->close(). tiny method, big energy πŸ’…

🌈 open_write($fh, $append)

Performs an $fh->open(">$file") or $fh->open(">>$file") if $append is defined. Returns the filehandle on success or undef on failure. so if $append is defined you're appending, periodt πŸ”₯

🧚 close_write($fh)

Performs a $fh->close(). yes, same as close_read. she's consistent πŸ’œ

πŸ‘‘ seek($fh, $pos, $wence)

Performs a $fh->seek($pos, $wence). See IO::Seekable. (and yes, it's spelled wence β€” we don't make the rules, we just document them πŸ™ˆ)

⭐ utime($atime, $mtime, @files)

Performs a utime() on the file(s). It changes the access time and mod time of those files. two timestamps, many files, one iconic call πŸŽ€


🌸 AUTHOR 🌸

David Davis, <xantus@cpan.org>, http://teknikill.net/


πŸ’œ LICENSE πŸ’œ

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. 🫢


✨ SEE ALSO ✨


and that's the whole page bestie, no crumbs left πŸ’… perl v5.36.0, dated 2022-11-19 β€” so like, a vintage icon, and still eating. bye, ily, go read perlfunc πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from