NAME
File::Properties - Perl module representing properties of a disk file
SYNOPSIS
use File::Properties;
my $fpc = File::Properties->cache('cache.db');
my $fp = File::Properties->new('/path/to/file', $fpc);
print "File properties:\n" . $fp->string . "\n";
An alternative approach is to use the File::Properties::PropsCache
module for construction of the cache and File::Properties objects:
use File::Properties::PropsCache;
my $fpc = File::Properties::PropsCache->new('cache.db');
my $fp = $fpc->properties('/path/to/file');
print "File properties:\n" . $fp->string . "\n";
ABSTRACT
File::Properties is a Perl module representing properties of
a disk file, with emphasis on media files.
DESCRIPTION
This module provides a class representing properties of a disk file,
with particular emphasis on media (image, video, and audio)
files. The mime type and a SHA-2 digest can be computed for any
regular file, and these properties are also available for the
content of bzip2 and gzip compressed files. Media file properties
consist of mime type and file type as extracted by Image::Exiftool,
the media type ('image', 'video', or 'audio'), the modification
date, and a hash representing the full EXIF data. For image files, a
digest of the image pixel data is also available. If a reference to
a File::Properties::Cache object is specified in the constructor,
access to the properties is via the cache. Most of the methods are
inherited from File::Properties::Media, from which it is derived.
- new
-
my $fp = File::Properties->new($path, $fpc);
Constructs a new File::Properties object.
- path
-
print "Canonical path: " . $fp->path . "\n";
Determine the canonical path of the represented file. This method is inherited from the File::Properties::Generic base class.
- device
-
print "Device number: " . $fp->device . "\n";
Determine the device number of the represented file. This method is inherited from the File::Properties::Generic base class.
- inode
-
print "Inode number: " . $fp->inode . "\n";
Determine the inode number of the represented file. This method is inherited from the File::Properties::Generic base class.
- size
-
print "File size: " . $fp->size . "\n";
Determine the size of the represented file. This method is inherited from the File::Properties::Generic base class.
- mtime
-
print "Modification time: " . $fp->mtime . "\n";
Determine the modification time of the represented file. This method is inherited from the File::Properties::Generic base class.
- mode
-
print "File mode: " . $fp->mode . "\n";
Determine the file mode integer (representing permissions and type) for the represented file. This method is inherited from the File::Properties::Generic base class.
- children
-
my $chsh = $fpg->children;
If the represented file is a directory, return a hash mapping file names within that directory to corresponding File::Properties object references. This method is inherited from the File::Properties::Generic base class.
- isreg
-
print (($fp->isreg)?"Is regular file\n":"Not regular file\n");
Determine if the represented file is a regular file. This method is inherited from the File::Properties::Generic base class.
- isdir
-
print (($fp->isdir)?"Is directory\n":"Not directory\n");
Determine if the represented file is a directory. This method is inherited from the File::Properties::Generic base class.
- mmimetype
-
print "Media mime type: " . $fp->mmimetype . "\n";
Determine the media mime type of the represented file. This is the mime type determined by Image::Exiftool if the file is a media file, otherwise it is the same as the value returned by the cmimetype method. This method is inherited from the File::Properties::Media base class.
- cmimetype
-
print "Content mime type: " . $fp->cmimetype . "\n";
Determine the content mime type of the represented file. This is the mime type of the compressed content for a gzip or bzip2 compressed file, otherwise it is the same as the value returned by the mimetype method. This method is inherited from the File::Properties::Compressed base class.
- mimetype
-
print "Mime type: " . $fp->mimetype . "\n";
Determine the mime type of the represented file. This method is inherited from the File::Properties::Regular base class.
- mfiletype
-
print "Media file type: " . $fp->mfiletype . "\n";
Determine the media file type, determined by Image::Exiftool, of the represented file. This method is inherited from the File::Properties::Media base class.
- mediatype
-
print "Media type: " . $fp->mediatype . "\n";
Determine the media type (the initial part of mime type, e.g. 'image') of the represented file. This method is inherited from the File::Properties::Media base class.
- idigest
-
print "Image digest: " . $fp->idigest . "\n";
Determine a SHA-2 digest of the pixel data in an image file.
- cdigest
-
print "Content digest: " . $fp->cdigest . "\n";
Determine the file content digest for the represented file. This is a SHA-2 digest of the compressed content for a gzip or bzip2 compressed file, otherwise it is the same as the value returned by the digest method. This method is inherited from the File::Properties::Compressed base class.
- digest
-
print "File digest: " . $fp->digest . "\n";
Determine a SHA-2 digest of the represented file. This method is inherited from the File::Properties::Regular base class.
- datemod
-
print "Modification date: " . $fp->datemod . "\n";
Determine the EXIF modification date. This method is inherited from the File::Properties::Media base class.
- exifhash
-
my $exh = $fpm->exifhash;
Return a hash mapping EXIF tags names to their values. This method is inherited from the File::Properties::Media base class.
- iscompressed
-
print "Is a compressed file\n" if ($fp->iscompressed);
Determine whether the file is a gzip or bzip2 compressed file. This method is inherited from the File::Properties::Compressed base class.
- ismedia
-
print "Is a media file\n" if ($fp->ismedia);
Determine whether the file is a media file. This method is inherited from the File::Properties::Media base class.
- isimage
-
print "Is an image file\n" if ($fp->isimage);
Determine whether the file is an image file.
- string
-
print $fp->string . "\n";
Construct a string representing the object data.
- cachestatus
-
if ($fp->cachestatus) { printf("All properties were retrieved from cache\n"); } elsif ($fp->cachestatus( $File::Properties::Regular::CacheTableName) { printf("Regular file properties were retrieved from cache\n"); }
Determine whether properties were retrieved from the cache
- _cacheinit
-
$fp->_cacheinit($fpc, $options_hash);
Initialise the regular file properties cache table in the cache referred to by the File::Properties::Cache reference argument.
- _cacheexpire
-
$fp->_cacheexpire($fpc, 365);
Remove all cache data older (based on insertion date) than the specified number of days.
- _cacheclean
-
$fp->_cacheclean($fpc);
Remove all cache data for which the corresponding files can no longer be found on disk.
WARNING
This initial release of the module has not been extensively tested, but is released in its current state in the hope that others may find it useful. While they will be avoided as far as possible, incompatible interface changes may become necessary in a later release.
SEE ALSO
File::Properties::Cache, File::Properties::Media, File::Properties::Image
AUTHOR
Brendt Wohlberg <wohl@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2010,2011 by Brendt Wohlberg
This library is available under the terms of the GNU General Public License (GPL), described in the LICENSE file included in this distribution.