Badger
Badger copied to clipboard
Badger::Filesystem::File::directory yields a Badger::Filesystem::Directory without a volume
Badger::Filesystem::File::directory
and Badger::Filesystem::File::parent
yield a Badger::Filesystem::Directory
that omits the File
's volume part. Example:
use Badger::Filesystem 'FS';
$file = FS->file('C:/path/to/file.txt'); # Badger::Filesystem::File
$file->path; # 'C:\path\to\file.txt', OK
$file->volume; # 'C:', OK
$dir = $file->directory; # Badger::Filesystem::Directory
$dir->path; # '\path\to\file.txt', NOK
$dir->volume; # '', NOK
$parent = $file->parent; # Badger::Filesystem::Directory
$parent->volume; # '', NOK
I think that File::directory
is intended to return only the directory part of the argument's path, as a scalar, similar to how File::volume
and File::name
return the argument path's volume and file name, respectively, as scalars. This is what http://badgerpower.com/docs/Badger/Filesystem/File.html#method_directory_dir_base suggests, though Badger::Filesystem::File
's POD says
$file->directory; # parent directory
which says "parent directory" rather than "directory part" -- which aren't equivalent.
And File::parent
(inherited from Path
) is intended to return an object representing the parent of the argument (says http://badgerpower.com/docs/Badger/Filesystem/Path.html#method_parent_skip_generations_up) -- which returned object should therefore include the volume part of the argument, but currently doesn't.
With these changes, File::directory
would return the directory part as a scalar, and File::parent
would returns a Directory
representing the parent directory of the argument, including the volume part.