NAME
Sys::Export::VFAT::Directory - Represents a case-folded directory in VFAT
DESCRIPTION
Both Microsoft VFAT and ISO9660 filesystems use case-insensitive filenames with a secondary "short" name limited to 8.3 characters, though they differ slightly in what characters are allowed in a filename. This object represents one of those directories as it is being assembled, with short names added automatically for a set of long names.
The "case folding" function is lc, rather than fc, since lc is the closest Perl approximation to the folding that Microsoft uses.
CONSTRUCTORS
new
my $dir= Sys::Export::VFAT::Directory->new(%attrs);
Accepts attributes name, parent, file, and entries.
ATTRIBUTES
name
Path string or other identifier for debugging purposes.
parent
A weak reference to the parent directory, or undef at the root.
is_root
True if parent is undef.
file
A reference to the File object which holds (or will hold) the encoding of this directory.
entries
An arrayref of directory entry hashrefs. This does not include '.' and '..' entries.
ent_by_name
A hashref of case-folded unicode long filename to entries. If the short name of an entry is defined, it is also added to this hash to ensure that long and short names do not conflict.
METHODS
entry
my $ent= $dir->entry($name);
Return a directory entry by case-folded name.
add
$ent= $dir->add($name, $file, %other_attrs);
Add a new name / file pair to the list of directory entries, along with any additional attributes you want to be part of the directory entry. If the name is valid as a short filename, this automatically sets the ->{shortname} attribute.
Croaks if the filename is invalid, or if the name is already used.
Returns the hashref storing the directory entry.
is_valid_name
$bool= $dir->is_valid_name($name)
Returns true if the name is valid for the filesystem type.
is_valid_shortname
$bool= $dir->is_valid_shortname($name)
Returns true if the name is valid as a short 8.3 filename.
remove_invalid_shortname_chars
$name= $dir->remove_invalid_shortname_chars($name, $replacement);
Perform a s/[invalid]/$replacement/gr on the name, using the set of invalid characters for this filesystem's short filenames.
find_unused_shortname
$short= $dir->find_unused_shortname($longname);
Given a unicode "long name", calculate a 8.3 "short name" which doesn't conflict with any of the existing names.
build_shortnames
For every directory entry lacking a shortname, calculate one and update the directory entry and the "ent_by_name" hash.
Directory Entries
Directory entries can have the following hash keys:
- name
-
A unicode "long" name
- shortname
-
A FAT "short" name in 8.3 notation. This must be bytes, and is fairly restricted in the ASCII range, but may contain high-bit bytes for an unspecified BIOS character encoding.
- file
-
A reference to a File object (::VFAT::File or ::ISO9660::File).
They may also contain other keys specific to the filesystem type.
VERSION
version 0.005
AUTHOR
Michael Conrad <mike@nrdvana.net>
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Michael Conrad.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.