Parano...:Block(3pm)
π Paranoid::IO::FileMultiplexer::Block π
okay so bestie, you just pulled up Parano...:Block(3pm) β that's the perl User Contributed Perl Documentation for section 3pm β and it's er, giving β¨ block-level allocator/accessor β¨. no cap, that's literally the whole vibe of this page. it's the plumbing behind Paranoid::IO::FileMultiplexer, so let's get into it π«Ά
β¨ NAME β¨
Paranoid::IO::FileMultiplexer::Block β Block-level Allocator/Accessor π
π VERSION π
$Id: lib/Paranoid/IO/FileMultiplexer/Block.pm, 2.10 2022/03/08 00:01:04
acorliss Exp $
that's version 2.10, dated 2022/03/08 00:01:04, by acorliss, obviously π
π¦ SYNOPSIS π¦
$obj = Paranoid::IO::FileMultiplexer::Block->new(
$filename, $bnum, $bsize);
$rv = $obj->allocate;
$bn = $obj->blockNum;
$bs = $obj->blockSize;
$minp = $obj->minPos;
$maxp = $obj->maxPos;
$bytesWritten = $obj->bwrite($content);
$bytesWritten = $obj->bwrite($content, $start );
$bytesWritten = $obj->bwrite($content, $start, $length );
$bytesWritten = $obj->bwrite($content, $start, $length, $offset );
$bytesRead = $obj->bread(\$content);
$bytesRead = $obj->bread(\$content, $start, $bytes);
$bytesRead = $obj->bread(\$content, undef, $bytes);
$bytesRead = $obj->bread(\$content, $start, $bytes);
$rv = $obj->recalibrate;
π DESCRIPTION π
okay so the tea βοΈ: this class is not meant to be used directly. it's part of the Paranoid::IO::FileMultiplexer functionality, and it's primarily a base class β other critical classes get derived from it. it's the momager, not the main character π¬
this module presumes that whatever file it's being used on has already been opened in the appropriate mode, and that the Paranoid::IO flock stack has been enabled. bestie, that setup is not on you β for the purposes of Paranoid::IO::FileMultiplexer, that's done inside that class. periodt π
πΈ SUBROUTINES/METHODS πΈ
π new
$obj = Paranoid::IO::FileMultiplexer::Block->new(
$filename, $bnum, $bsize);
this creates a brand-new instance of a block object β¨ it needs three things:
- the filename β so it can retrieve the cached file handle from
Paranoid::IO - the number of the block β using zero-based indexing, iykyk
- the size of the block
and ngl, the source says, word for word: "It will block size and the block number to calculate its actual position within the file." so yeah β it takes the block size and the block number and uses them to calculate its actual position within the file. iconic.
π blockNum
$bn = $obj->blockNum;
hands you back the object's assigned block number. that's it, that's the method π
π¦ blockSize
$bs = $obj->blockSize;
returns the object's assigned block size. short and sweet, we love a low-maintenance method.
πΈ minPos
$minp = $obj->minPos;
returns the minimum file position for the block βοΈ
π maxPos
$maxp = $obj->maxPos;
returns the maximum file position for the block π
π allocate
$rv = $obj->allocate;
this one attempts to allocate the block on the file system, and returns a boolean telling you whether it slayed or flopped π«Ά
β οΈ bestie, listen: this method will fail if you try to allocate a block that's already been allocated, or a block whose file position is beyond the current end of the file. in other words β blocks must be allocated in sequence. no skipping ahead, no cutting the line π
β¨ recalibrate
$rv = $obj->recalibrate;
recalculates the minimum/maximum file position based on the currently set block size. and this is the important part: this should always be called after any change to blockSize. always. no exceptions, no vibes-based shortcuts π₯
π bwrite
$bytesWritten = $obj->bwrite($content);
$bytesWritten = $obj->bwrite($content, $start );
$bytesWritten = $obj->bwrite($content, $start, $length );
$bytesWritten = $obj->bwrite($content, $start, $length, $offset );
this method writes the passed $content to the block, while making sure the content does not overflow the block boundaries β boundaries are sacred π§
if the start position of the write is omitted, it writes from the beginning of the block. and if you do pass a start position, heads up: that position is relative to the block, not the file π« so you'd specify values from a range of o to (blockSize - 1).
and this part is intentional: this method is designed so you can pass more content than will fit inside a block, and it'll only write as much as will fit. so the calling code should use the return value to figure out what remains to be written in other blocks, as needed. it's giving "you handle the rest, bestie" πββοΈ
π bread
$bytesRead = $obj->bread(\$content);
$bytesRead = $obj->bread(\$content, $start);
$bytesRead = $obj->bread(\$content, undef, $bytes);
$bytesRead = $obj->bread(\$content, $start, $bytes);
reads the content of the block, while making sure the content read does not go beyond the borders of the block. if the start position of the read is omitted, it reads from the beginning of the block. and just like bwrite, that position is relative to the beginning of the block, not the file βοΈ
also intentional (icons only): you can request more data than can fit within the block, and it'll return only what the block contains. the calling code should use the return value to figure out what remains to be read from other blocks, as needed. ate and left no crumbs π½οΈ
π§ DEPENDENCIES π§
FcntlParanoidParanoid::DebugParanoid::IO
π BUGS AND LIMITATIONS π
soβ¦ the section is here, and it is empty. no bugs listed, no limitations listed. not a single complaint. she simply chose peace πβ¨
π«Ά AUTHOR π«Ά
Arthur Corliss (corliss@digitalmages.com)
βοΈ LICENSE AND COPYRIGHT βοΈ
This software is free software. Similar to Perl, you can redistribute it and/or modify it under the terms of either:
a) the GNU General Public License
<https://www.gnu.org/licenses/gpl-1.0.html> as published by the
Free Software Foundation <http://www.fsf.org/>; either version 1
<https://www.gnu.org/licenses/gpl-1.0.html>, or any later version
<https://www.gnu.org/licenses/license-list.html#GNUGPL>, or
b) the Artistic License 2.0
<https://opensource.org/licenses/Artistic-2.0>,
subject to the following additional term: No trademark rights to "Paranoid" have been or are conveyed under any of the above licenses. However, "Paranoid" may be used fairly to describe this unmodified software, in good faith, but not as a trademark.
(c) 2005 - 2021, Arthur Corliss (corliss@digitalmages.com) (tm) 2008 - 2021, Paranoid Inc. (www.paranoid.com)
and that's the whole page bestie π this gorgeous thing was built by perl v5.38.2, dated 2024-03-07, and you read it all the way to the end β main character energy fr fr ππ¦β¨
π¦ where this page comes from
- debian trixie: libparanoid-perl 2.10-2 Β· other
- ubuntu resolute: libparanoid-perl 2.10-2 Β· other
- ubuntu stonking: libparanoid-perl 2.10-2 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms