Dale Amon > FileHash-0.01-3 > FileHash::Entry

Download:
FileHash-0.01-3.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

 FileHash::Entry - Container for data about a file.

SYNOPSIS ^

 use FileHash::Entry;
 $obj  = FileHash::Entry->alloc;
 $ver  = FileHash::Entry->dumpversion;

 $obj  = $obj->init         ($path);
 $obj  = $obj->initFromStat ($path);
 $obj  = $obj->initFromLine ($format,$line);
 $obj  = $obj->initFromDump ($fh);


 $str  = $obj->sprint;
 $obj  = $obj->print;
 $obj  = $obj->fprint($fh);
 $obj  = $obj->dump  ($fh);

 $path = $obj->path;

 $atime               = $obj->atime;
 $blocksizePreference = $obj->blocksizePreference;
 $blocksAllocated     = $obj->blocksAllocated;
 $ctime               = $obj->ctime;
 $device              = $obj->device;
 $deviceNumber        = $obj->deviceNumber;
 $deviceSpecialId     = $obj->deviceSpecialId;
 $directory           = $obj->directory;
 $file                = $obj->file;
 $gid                 = $obj->gid;
 $gidName             = $obj->gidName;
 $hardlinks           = $obj->hardlinks;
 $inode               = $obj->inode;
 $md5sum              = $obj->md5sum;
 $mode                = $obj->mode;
 $mtime               = $obj->mtime;
 $sizeBytes           = $obj->sizeBytes;
 $uid                 = $obj->uid;
 $uidName             = $obj->uidName;

Inheritance UNIVERSAL ^

Description ^

This is an internal class used by FileHashes.

Entry objects are containers for information about files collected from various sources.

Examples ^

 use FileHash::Entry;

 # Create an entry by collecting metadata about a live file.
 my $a = FileHash::Entry->alloc;
 $a->initFromStat ("/root/myfile");

 # Create another Entry by parsing a line of data.
 my $f = FileHash::FormatString->alloc;
 $f->init ("path md5sum sizeBytes");
 my $b = FileHash::Entry->alloc;
 $b->initFromLine ($f, "/root/myfile 0bdebef6bc59cabe489442ef9ddecf5f 10050");

 # Dump the object data to a file.
 open $fh, ">mydump";
 $b->dump ($fh);
 close $fh;

 # Reload the dumped object data.
 my $c = FileHash::Entry->alloc;
 open $fh, "<mydump";
 $c->initFromDump ($fh);
 close $fh;

 # print data on the console.
 $c->print;

Class Variables ^

 None.

Instance Variables ^

In most cases an item will be undef if it is not available via the source of information used to create the FileHash::Entry.

 device                 File device portion of file path, non Unix systems.
 directory              File directory portion of file path.
 file                   File name portion of file path.
 deviceNumber           Device number.
 sizeBytes              Size of file in bytes.
 uid                    User id number.
 uidName                User name in ascii.
 gid                    Group id number.
 gidName                Group name in ascii.
 mode                   File access mode integer.
 atime                  Access time in nonleap seconds since 19700101 UTC.
 mtime                  Modify time in nonleap seconds since 19700101 UTC.
 ctime                  Create time in nonleap seconds since 19700101 UTC.
 inode                  File Inode number.
 hardlinks              Number of hard links to file.
 deviceSpecialId        Device special id, integer.
 blocksizePreference    Preferred block size in bytes.
 blocksAllocated        Number of blocks allocated to the file.
 md5sum                 md5sum of file content.
 notepad                A Notepad object to record unusual events.

Class Methods ^

$obj = FileHash::Entry->alloc

Allocate an empty FileHash Entry object.

$ver = FileHash::Entry->dumpversion

Return the FileHash Entry dump format version id.

Instance Methods for printing ^

$atime = $obj->atime

Return the file atime or 0 if not known.

$blocksizePreference = $obj->blocksizePreference

Return the file blocksizePreference or "undef" if not known.

$blocksAllocated = $obj->blocksAllocated

Return the file blocksAllocated or "undef" if not known.

$ctime = $obj->ctime

Return the file ctime or 0 if not known.

$device = $obj->device

Return the file device or "" if not known.

$deviceNumber = $obj->deviceNumber

Return the file deviceNumber or "undef" if not known.

$deviceSpecialId = $obj->deviceSpecialId

Return the file deviceSpecialId or "undef" if not known.

$directory = $obj->directory

Return the file directory or "" if not known.

$file = $obj->file

Return the file name or "" if not known.

$gid = $obj->gid

Return the file gid or "undef" if not known.

$gidName = $obj->gidName

return the file gidName or "undef" if not known.

$hardlinks = $obj->hardlinks

Return the file hardlinks or "undef" if not known.

$inode = $obj->inode

Return the file inodes or "undef" if not known.

$md5sum = $obj->md5sum

Return the file md5sum or "undef" if not known.

$mode = $obj->mode

Return the file mode or "undef" if not known.

$mtime = $obj->mtime

Return the file mtime or 0 if not known.

$sizeBytes = $obj->sizeBytes

Return the file size in bytes or 0 if not known.

$uid = $obj->uid

Return the file uid or "undef" if not known.

$uidName = $obj->uidName

Return the file uidName or "undef" if not known.

Instance Methods ^

$obj = $obj->dump($fh)

Dump contents of the file data entry to one line in the specified file defined by the opened file handle $fh.

Synonym for fprint.

$obj = $obj->fprint($fh)

Dump contents of the file data entry to one line in the specified file defined by the opened file handle $fh.

Synonym for dump.

$obj = $obj->init ($path)

Initialize a FileHash Entry object to contain the path name.

$obj = $obj->initFromDump ($fh)

Replace the alloc'd object with one recreated from a line of dump file data.

$obj = $obj->initFromLine ($format,$line)

Create a FileHash Entry from the information parsed out of a line of text. A format object defines what information is contained in that line.

$obj = $obj->initFromStat ($path)

Initialized an object with metadata collected via a 'stat' and 'md5sum' applied to the file at $path.

$obj = $obj->path

Return the full path name.

$obj = $obj->print

Dump contents of the file data entry as one line on stdout.

$str = $obj->sprint

Dump contents of the file data entry as a string. The string is not terminated by a newline.

Private Class Method ^

 None.

Private Instance Methods ^

@lexemes = $obj->_lexical_parse ($line,$fields)

This is the point at which the field data is split it needs to handle a mix of blank delimited fields and quoted fields. If want to parse lines of code here, you'll just have to write your own subclass and override this method.

Errors and Warnings ^

 Lots.

KNOWN BUGS ^

 See TODO.

SEE ALSO ^

 File::Spec, Digest::MD5, Fault::Notepad, Fault::Logger, 
 FileHash::FormatString, Data::Dumper.

AUTHOR ^

Dale Amon <amon@vnl.com>

syntax highlighting: