NAME
DataStore::CAS::FS::Dir - Object representing a directory of file entries, indexed by filename.
VERSION
version 0.010100_02
SYNOPSIS
my $dir= DataStore::CAS::FS::Dir->new(
file => $cas_file,
format => $codec_name,
entries => \@entries,
metadata => $metadata
);
DESCRIPTION
Directory objects have a very basic API of being able to fetch an entry by name (optionally case-insensitive, as the user chooses), and iterate all entries.
Directory objects are IMMUTABLE, as are the DirEnt objects they return.
ATTRIBUTES
file
Read-only, Required. The DataStore::CAS::File this directory was deserialized from.
store
Alias for file->store
hash
Alias for file->hash
size
Alias for file->size
format
The format string that identifies this directory encoding.
metadata
A hashref of arbitrary name/value pairs attached to the directory at the time it was written. DO NOT MODIFY. (In the future, this might be protected by Perl's internal const mechanism)
METHODS
new
$dir= $class->new( %params | \%params )
Create a new basic Dir object. The required parameters are file
, and format
. metadata
will default to an empty hashref, and entries
will default to an empty list.
The entries
parameter is not a public attribute, and is stored internally as _entries
. This is because not all subclasses will have an array of entries available. Use the method iterator
instead.
iterator
$i= $dir->iterator;
while (my $next= $i->()) { ... }
Returns an iterator over the entries in the directory.
The iterator is a coderef where each successive call returns the next DirEnt. Returns undef at the end of the list. Entries are not guaranteed to be in any order, or even to be unique names. (in particular, because of case sensitivity rules)
get_entry
$dirEnt= $dir->get_entry($name, %flags)
Get a directory entry by name.
If $flags{case_insensitive}
is true, then the directory will attempt to do a case-folding lookup on the given name. Note that all directories are case-sensitive when written, and the case-insensitive feature is meant to help emulate Windows-like behavior. In other words, you might have two entries that differ only by case, and the caseless lookup will pick one arbitrarily.
AUTHOR
Michael Conrad <mconrad@intellitree.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Michael Conrad, and IntelliTree Solutions llc.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.