.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Paranoid::IO::FileMultiplexer::Block::FileHeader 3pm" .TH Paranoid::IO::FileMultiplexer::Block::FileHeader 3pm 2024-03-07 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Paranoid::IO::FileMultiplexer::Block::FileHeader \- File Header Block .SH VERSION .IX Header "VERSION" \&\f(CW$Id:\fR lib/Paranoid/IO/FileMultiplexer/Block/FileHeader.pm, 2.10 2022/03/08 00:01:04 acorliss Exp $ .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 2 \& $obj = Paranoid::IO::FileMultiplexer::Block::FileHeader\->new( \& $filename, $bsize); \& \& $count = $obj\->blocks; \& $version = $obj\->version; \& %streams = $obj\->streams; \& $max = $obj\->maxStreams; \& %model = $obj\->model; \& \& $rv = $obj\->writeSig; \& $rv = $obj\->readSig; \& $rv = $obj\->writeBlocks; \& $count = $obj\->readBlocks; \& $rv = $obj\->incrBlocks; \& $rv = $obj\->validateBlocks; \& \& $rv = $obj\->writeStreams; \& $rv = $obj\->readStreams; \& $rv = $obj\->addStream($sname, $bn); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This class is not meant to be used directly, but as part of the Paranoid::IO::FileMultiplexer functionality. This provides functionality necessary for manipulation of the file header block. .PP This module does presume that whatever file it is being used on has already been opened in the appropriate mode, and that the Paranoid::IO flock stack has been enabled. For the purposes of Paranoid::IO::FileMultiplexer, this is done in that class. .SH SUBROUTINES/METHODS .IX Header "SUBROUTINES/METHODS" .SS new .IX Subsection "new" .Vb 2 \& $obj = \& Paranoid::IO::FileMultiplexer::Block::FileHeader\->new($file, $blockSize); .Ve .PP This creates a new instance of a file header block object. It requires the filename in order to retrieve the cached file handle from Paranoid::IO, and the size of the block. This always writes to the first block of the file. .PP \&\fBNOTE:\fR creating an object does not automatically create the file and/or write a signature. That must be done using the methods below. .SS blocks .IX Subsection "blocks" .Vb 1 \& $count = $obj\->blocks; .Ve .PP This method returns the value of the blocks field in the file header. This is the total number of blocks allocated in the file to date. Note that this is only the cached value stored in the object. Other methods are provided for writing and reading the value from the file. .SS version .IX Subsection "version" .Vb 1 \& $ver = $obj\->version; .Ve .PP This method returns the file format version as a string. .SS streams .IX Subsection "streams" .Vb 1 \& %streams = $obj\->streams; .Ve .PP This method returns a hash of streams allocated in the file, in the format of \&\fIstream name\fR => \fIblock number\fR. .SS maxStreams .IX Subsection "maxStreams" .Vb 1 \& $max = $obj\->maxStreams; .Ve .PP This method returns the maximum number of streams supported by this file header. .SS model .IX Subsection "model" .Vb 1 \& $stats = $obj\->model; .Ve .PP This method returns a hash with some basic statistical information on the file, in both raw and human-friendly values. The information provided is as follows: .PP .Vb 11 \& Key Description \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& intSize Size of Perl\*(Aqs native integers in bits \& curFileSize Current file size in bytes \& curFSHuman Current file size expressed w/unit suffixes \& curStreams Current number of streams allocated \& maxFileSize Maximum file size supported with Perl \& maxFSHuman Maximum file size expressed w/unit suffixes \& maxStreams Maximum number of streams that can be allocated \& maxStreamSize Maximum stream size \& maxSSHuman Maximum stream size expressed w/unit suffixes .Ve .SS writeSig .IX Subsection "writeSig" .Vb 1 \& $rv = $obj\->writeSig; .Ve .PP This method writes the file header signature to disk, returning a boolean value denoting its success. Note that the signature contains the file format, version, block size, and number of allocated blocks, but not the list of allocated streams. .SS readSig .IX Subsection "readSig" .Vb 1 \& $rv = $obj\->readSig; .Ve .PP This method reads the file header signature from disk and performs basic validation that the information in it is acceptable. It validates that the file size matches the block size * block count, that the block size is an acceptable value, and the file format and version are supported. .PP If the method call was successful it will update the cached values in the object. Note that this is only the signature values, not the stream index records. .SS writeBlocks .IX Subsection "writeBlocks" .Vb 1 \& $rv = $obj\->writeBlocks($count); .Ve .PP This method writes the passed block count value to disk, and returns a boolean value denoting success. .SS readBlocks .IX Subsection "readBlocks" .Vb 1 \& $count = $obj\->readBlocks; .Ve .PP This method reads the block count field from disk and returns it. If there are any errors reading or extracting the value, it will return undef. .SS incrBlocks .IX Subsection "incrBlocks" .Vb 1 \& $rv = $obj\->incrBlocks; .Ve .PP This method calls writeBlocks with a value of one greater that what's currently cached. .SS validateBlocks .IX Subsection "validateBlocks" .Vb 1 \& $rv = $obj\->validateBlocks; .Ve .PP This method compares the cached block count value to what's actually written in the file. This is useful for determining whether an external process has potentially modified the file. .SS writeStreams .IX Subsection "writeStreams" .Vb 1 \& $rv = $obj\->writeStreams; .Ve .PP This method writes the stream index records to the header block, and returns a boolean denoting success. .SS readStreams .IX Subsection "readStreams" .Vb 1 \& $rv = $obj\->readStreams; .Ve .PP This method reads the stream index records from the file, and returns a boolean value denoting success. If the read is successful, this will update the cached streams information in the object. .SS addStream .IX Subsection "addStream" .Vb 1 \& $rv = $obj\->addStream($sname, $bn); .Ve .PP This method does some basic validation of the requested stream, and if it passes, updates the stream indices on the disk. .SH DEPENDENCIES .IX Header "DEPENDENCIES" .IP o 4 .IX Item "o" Fcntl .IP o 4 .IX Item "o" Paranoid .IP o 4 .IX Item "o" Paranoid::Debug .IP o 4 .IX Item "o" Paranoid::Data .IP o 4 .IX Item "o" Paranoid::IO .IP o 4 .IX Item "o" Paranoid::IO::FileMultiplexer::Block .IP o 4 .IX Item "o" Paranoid::IO::FileMultiplexer::Block::BATHeader .IP o 4 .IX Item "o" Paranoid::IO::FileMultiplexer::Block::StreamHeader .SH "BUGS AND LIMITATIONS" .IX Header "BUGS AND LIMITATIONS" .SH AUTHOR .IX Header "AUTHOR" Arthur Corliss (corliss@digitalmages.com) .SH "LICENSE AND COPYRIGHT" .IX Header "LICENSE AND COPYRIGHT" This software is free software. Similar to Perl, you can redistribute it and/or modify it under the terms of either: .PP .Vb 7 \& a) the GNU General Public License \& as published by the \& Free Software Foundation ; either version 1 \& , or any later version \& , or \& b) the Artistic License 2.0 \& , .Ve .PP 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. .PP (c) 2005 \- 2021, Arthur Corliss (corliss@digitalmages.com) (tm) 2008 \- 2021, Paranoid Inc. (www.paranoid.com)