NAME
File::Information::Inode - generic module for extracting information from filesystems
VERSION
version v0.15
SYNOPSIS
use File::Information;
my File::Information $instance = File::Information->new(%config);
my File::Information::Inode $inode = $instance->for_handle($handle);
my File::Information::Inode $inode = $instance->for_link($path)->inode;
Note: This package inherits from File::Information::Base.
This module represents an inode on a filesystem. An inode contains basic file metadata (such as type and size) and the file's content. Inodes are commonly represented by an inode number (but this is subject to filesystem implementation and limitations). In order to access inodes they most commonly need to have at least one hardlink pointing to them. See also File::Information::Link.
METHODS
filesystem
my File::Information::Filesystem $filesystem = $inode->filesystem([ %opts ]);
Provides access to the filesystem object for the filesystem this inode is on. Dies if no filesystem could be found.
Takes the following options (all optional):
default-
The value to be returned when no filesystem could be found. This can also be
undefwhich switches fromdie-ing when no value is available to returningundef.
tagpool
my File::Information::Tagpool $tagpool = $inode->tagpool;
# or:
my @tagpool = $inode->tagpool;
This method returns any tagpool instances this file is part of. If called in scalar context only one is returned and if none have been found this function dies. If called in list context the list is returned and an empty list is returned in case none have been found.
If called in scalar context it is not clear which is returned in case the file is part of multiple pools. However the result is cached and for the same instance of this object always the same tagpool instance is returned.
peek
my $data = $inode->peek( [ %opts ] );
Peeks the first few bytes of a file. The main usage of this method is to check for magic numbers.
The following options (all optional) are supported:
wanted-
The number of bytes wanted. If this number of bytes can't be provided less is returned.
required-
The number of bytes that are needed. If this number of bytes can't be provided the method
dies.
open_handle
my $handle = $inode->open_handle( [ $mode ] );
(experimental since v0.15)
This method opens a new file handle to this inode. This can be used to read or write data from or to this inode.
$mode is the same as MODE in "open" in perlfunc. If no $mode is not given or undefined the file is opened for reading (as per <).
Note: Future versions of this method might change their interface. However calling without any parameters is likely to be the most future-proof way.
Note: All considerations of "binmode" in perlfunc apply to the freshly returned handle. Also seeking on the returned handle as well as closing it will not have an effect on other handles. Each returned handle is a fresh handle.
Note: If you want to read some data from the file consider to use "peek" as it often porvides a better alternative.
Note: Availability depends on the operating system, the filesystem, and the current state.
AUTHOR
Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2024-2025 by Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)