Files module

This module defines the abstract access methods to the files of the source-tree, independent of the repository format.

new ($config)

new is Files object constructor. It dispatches to the specific constructor based on its first argument.

  1. $config

    a reference to the hash containing configuration parameters for this tree

getdir ($pathname, $releaseid)

getdir returns a directory content in an array.

  1. $pathname

    a string containing the path relative to 'sourceroot'

  2. $releaseid

    the release (or version) in which $pathname is expected to be found

Function result is undef if directory does not exist in this version.

getfile ($pathname, $releaseid)

getfile returns a file content in a string.

  1. $pathname

    a string containing the path relative to 'sourceroot'

  2. $releaseid

    the release (or version) in which $pathname is expected to be found

Function result is undef if file does not exist in this version.

getannotations ($pathname, $releaseid)

getannotations returns the annotations for the designated file.

  1. $pathname

    a string containing the path relative to 'sourceroot'

  2. $releaseid

    the release (or version) in which $pathname is expected to be found

An annotation is whatever auxiliary line information kept in the repository. There is none in plain files. It is the revision number the line was entered in CVS. It is the commit-id in GIT.

Function result is an empty list if there is no annotation or annotation retrieval is barred by lxr.conf.

IMPORTANT NOTICE:

getnextannotation ($pathname, $releaseid)

getnextannotation returns the annotation for the next line in the designated file.

  1. $pathname

    a string containing the path relative to 'sourceroot'

  2. $releaseid

    the release (or version) in which $pathname is expected to be found

An annotation is whatever auxiliary line information kept in the repository. There is none in plain files. It is the revision number the line was entered in CVS. It is the commit-id in GIT.

Function result is undefined if there is no more annotation or annotation retrieval is barred by lxr.conf.

truncateannotation ($string, $len)

truncateannotation truncate the annotation and returns the new length.

  1. $string

    a reference to a string containing the annotation

  2. $len

    an integer containing the desired length

The caller must leave room in his layout for an extra character to be inserted where truncation takes place. The returned string contains $len + 1 "characters" . Here, character means a display position on the screen but may need several bytes to be defined.

This default implementation truncates on left. It can be overriden in specific classes to truncate on right or use a different flag character or style.

getauthor ($pathname, $releaseid, $annotation)

getauthor returns the author of the designated revision.

  1. $pathname

    a string containing the path relative to 'sourceroot'

  2. $releaseid

    the release (or version) in which $pathname is expected to be found

  3. $annotation

    the annotation (see sub getannotations) whose author is looked for

    Caveat:

filerev ($pathname, $releaseid)

filerev returns the latest revision for the file.

  1. $pathname

    a string containing the path relative to 'sourceroot'

  2. $releaseid

    the release (or version) in which $pathname is expected to be found

For repositories that do not manage versions (i.e. plain files), return something making sense, but it does not need to be real.

getfilehandle ($pathname, $releaseid, $withannot)

getfilehandle returns a handle to the designated file for further access to the content.

getrawfilehandle is identical, except the file will be accessed in binary mode. By default, it is an alias for getfilehandle with third argument undefined. This method must be overridden if the specific object has requested the :utf8 layer to become a true "binary" access.

  1. $pathname

    a string containing the path relative to 'sourceroot'

  2. $releaseid

    the release (or version) in which $pathname is expected to be found

  3. $withannot

    "true" if annotations are also collected

Returning a file handle may require specific operations with the repository (check out, file extraction, …).

getfilesize ($pathname, $releaseid)

getfilesize returns the file size in bytes.

  1. $pathname

    a string containing the path relative to 'sourceroot'

  2. $releaseid

    the release (or version) in which $pathname is expected to be found

For some repositories, this may require extracting the file.

getfiletime ($pathname, $releaseid)

getfiletime returns the file last modification time.

  1. $pathname

    a string containing the path relative to 'sourceroot'

  2. $releaseid

    the release (or version) in which $pathname is expected to be found

For some repositories, this may require extracting the file.

isdir ($pathname, $releaseid)

isdir returns "true" if the designated path exists and is a directory.

  1. $pathname

    a string containing the path relative to 'sourceroot'

  2. $releaseid

    the release (or version) in which $pathname is expected to be found

Since testing for a directory is rather time-consuming, arrange to "canonise" paths at the end of httpinit so that directories always end with /. Test will be done only once, eventually adding / suffix. Afterwards, all is needed is test for the trailing slash.

This method is used when the existence must be confirmed, such as when processing an include link since it is independent from the currently displayed file.

isfile ($pathname, $releaseid)

isfile returns "true" if the designated path exists and is a file.

  1. $pathname

    a string containing the path relative to 'sourceroot'

  2. $releaseid

    the release (or version) in which $pathname is expected to be found

This method is used when the existence must be confirmed, such as when processing an include link since it is independent from the currently displayed file.

Note:

realfilename ($pathname, $releaseid)

realfilename returns a real filename with the same content as the designated path (or undef).

  1. $pathname

    a string containing the path relative to 'sourceroot'

  2. $releaseid

    the release (or version) in which $pathname is expected to be found

Extract content of the path from repository and stuff it into a temporary file whose name is returned.

Note:

releaserealfilename ($filename)

releaserealfilename erases the file created by realfilename.

  1. $filename

    a string containing the filename

Although some care is exercised to check $filename was created by realfilename, this test is not fool-proof. Use this method ONLY against files returned by realfilename.

Caveat:

_ignoredirs ($path, $node)

_ignoredirs is an internal (as indicated by _ prefix) filter utility to exclude directories containing any partial path defined in configuration parameters 'ignoredirs' and 'filterdirs'.

  1. $path

    a string containing the LXR full path for the parent directory

  2. $node

    a string containing the last directory element

Only the last part is tested for 'ignoredirs' since the parent is supposed to have been scanned by a previous step of the recursive directory tree traversal. If a higher element matched one of the 'ignoredirs' strings, that path part was filtered out and no further part is presented to this function.

'filterdirs' operates on the full path, i.e. $path concatenated with $node.

Note:

_ignorefiles ($path, $node)

_ignorefiles is an internal (as indicated by _ prefix) filter utility to exclude files containing patterns defined in configuration parameters 'ignorefiles' and 'filterfiles'.

  1. $path

    a string containing the LXR full path for the parent directory

  2. $node

    a string containing the file name

Only filename filtering is done for 'ignorefiles', i.e. the same filter is applied in every directory. Usually, it screens off "dot" files, editor backups, binaries, ...

'filterfiles' operates on the full path, i.e. concatenation of the parent directory $path and the filename $node.

Note: