App::Hashl - Partially hash files, check if files are equal etc.
use App::Hashl; my $hashl = App::Hashl->new(); # or: App::Hashl->new_from_file($database_file);
This manual documents App::Hashl version 1.01
App::Hashl contains utilities to hash the first n bytes of files, store and recall them, check if another file is already in the database and optionally ignore file hashes.
Returns a new App::Hashl object. Accepted parameters are:
How many bytes of a file to consider for the hash. Defaults to 4 MiB (4 * 2**20 bytes). 0 means read the whole file.
Returns the App::Hashl object saved to file by a prior $hashl->save call.
Returns bytes as a human-readable SI-size, such as "1.0k", "50.7M", "2.1G". The returned string is always six characters long.
Returns the SHA1 hash of the first few bytes (as configured via read_size) of file. Dies if file cannot be read.
Checks if hash is in the database. If it is, returns the filename it is associated with. If it is ignored, returns "// ignored" (subject to change). Otherwise, returns false.
Checks if file's hash is in the database. For the return value, see hash_in_db.
Returns the current read size. Note that once an App::Hashl object has been created, it is not possible to change the read size.
Returns a hashref describing the file. The layout is as follows:
hash => file's hash, mtime => mtime as UNIX timestamp, size => file size in bytes
If name does not exist in the database, returns undef.
Remove the file from the database.
Returns a list of all file names in the database.
Add a file to the database. Required keys in %data are:
relateve file name to store in the database
Full path to the file
If true: do not skip ignored files, unignore and re-add them instead
If the file already is in the database, it is only updated if both the file size and the mtime have changed.
Returns true if the file was actually added to the database, false if it is ignored or already present (and up-to-date).
Returns a list of all ignored file hashes.
Removes $file from the database and adds $path to the list of ignored file hashes.
Unignore the hash of $path.
Save the App::Hashl object with all data to $file. It can later be retrieved via new_from_file.
Copyright (C) 2011-2017 by Daniel Friesel <email@example.com>
0. You just DO WHAT THE FUCK YOU WANT TO.