CInbox (Common-Inbox)  0.1
Common functionality for ingesting files for archiving.
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes
TaskHashOutput Class Reference
Inheritance diagram for TaskHashOutput:
TaskHash CITask

List of all members.

Public Member Functions

 __construct (&$CIFolder)
 init ()
 run ()

Public Attributes

const TASK_LABEL = 'Write hash output'
const CONF_HASH_OUTPUT = 'HASH_OUTPUT'
const CONF_HASH_FILENAME = 'HASH_FILENAME'
const CONF_HASH_FILEFORMAT = 'HASH_FILEFORMAT'
const OPT_OUTPUT_FILE = 'file'
const OPT_OUTPUT_FOLDER = 'folder'
const OPT_HASH_FORMAT_GNU = 'gnu'
const OPT_HASH_FORMAT_WIN = 'win'
const OPT_HASH_FORMAT_MACOS = 'macos'

Static Public Attributes

static $OPT_HASH_OUTPUTS
static $OPT_HASH_FILEFORMATS

Protected Member Functions

 loadSettings ()
 isValidHashOutput ($option)
 isValidHashFileformat ($option)
 formatHash ($outputMask, $hashType, $hashCode, $filename)
 writeHashCodeFiles ($hashCodes, $targetFolder)
 saveHashesToFile ($file, $contents, $overwrite=false)
 appendHashcodes ($targetHashFile, $new)

Protected Attributes

 $hashOutput
 $hashFilename
 $hashFileformat

Detailed Description

Writes the generated source-hashes to target. Format and location can be set in config file.

Author:
Peter Bubestinger-Steindl (pb@av-rd.com)
See also:

Member Function Documentation

TaskHashOutput::appendHashcodes ( targetHashFile,
new 
) [protected]

Appends new hashcode lines to contents of an existing hashcode file.

The format of the hashcode file should be identical, otherwise the resulting file will be corrupt. Duplicate entries are removed (Works only if format is identical).

Returns the result as array of text-lines.

TaskHashOutput::formatHash ( outputMask,
hashType,
hashCode,
filename 
) [protected]

Returns one line for a hashcode output format, according to the format defined by $hashFormat.

Prepare everything so it's ready for processing.

Returns:
bool success True if init went fine, False if an error occurred.

Reimplemented from CITask.

TaskHashOutput::isValidHashFileformat ( option) [protected]

Checks if the given mode is a valid option for CONF_HASH_FILEFORMAT. Returns 'true' if it is valid - 'false' if not.

The check is case-sensitive, so you might want to normalize case before calling this.

TaskHashOutput::isValidHashOutput ( option) [protected]

Checks if the given mode is a valid option for CONF_HASH_OUTPUT. Returns 'true' if it is valid - 'false' if not.

The check is case-sensitive, so you might want to normalize case before calling this.

Load settings from config that are relevant for this task.

Reimplemented from TaskHash.

Perform the actual steps of this task.

Reimplemented from CITask.

TaskHashOutput::saveHashesToFile ( file,
contents,
overwrite = false 
) [protected]

Writes formatted hashcode lines to file. If file exists and $overwrite is false, then hashcode lines will be appended.

appendHashcodes

TaskHashOutput::writeHashCodeFiles ( hashCodes,
targetFolder 
) [protected]

Iterates through array $hashCodes and assembles each line for the output hash textfile, according to self::$OPT_HASH_FILEFORMATS.

Depending on the CONF_HASH_OUTPUT mode, the lines are written to the corresponding files on the target.

Existing hashcode files with the same name as defined by CONF_HASH_FILENAME will a) be overwritten (CONF_HASH_OUTPUT = file) b) be merged with the new hashcode lines (CONF_HASH_OUTPUT = folder) Please make sure that the hashcode format is identical in this case, because otherwise the resulting files will not work for automatic validation using tools like md5sum, etc.


Member Data Documentation

TaskHashOutput::$OPT_HASH_FILEFORMATS [static]
Initial value:
 array(
            self::OPT_HASH_FORMAT_GNU => "[@HASHCODE@]  [@FILENAME@]\n",
            self::OPT_HASH_FORMAT_WIN => "[@HASHCODE@]  [@FILENAME@]\r\n",
            self::OPT_HASH_FORMAT_MACOS => "[@FILENAME@]  [@HASHCODE@]\n",
            )
TaskHashOutput::$OPT_HASH_OUTPUTS [static]
Initial value:
 array(
            self::OPT_OUTPUT_FILE,
            self::OPT_OUTPUT_FOLDER,
            )

The documentation for this class was generated from the following file:
 All Classes Functions Variables