* Remove useless VersionArray parameter in maintain_version()
The 2nd argument, FileName *varray, is only ever NULL, so
remove it and simplify the code.
* Remove useless and unused VersionArray cache mechanism
* Simplify setting of file times on file close
The futimes(fd, ...) function allows changing the times of a file with
reference to an open file descriptor which allows us to avoid trying to
find a pathname by which utimes(path, ...) would operate on the inode
corresponding to the fd we have just closed.
* Remove unnecessary temporary variable for VersionArray
* In get_version_array() do not mix array and pointer access to VersionArray
* Improve {DSK} device handling of files with many versions
Somewhat dynamically allocate the version array storage, in chunks of
VERSIONARRAYCHUNKLENGTH (currently 200) allowing for up to
VERSIONARRAYMAXLENGTH (currently 2000) entries before reporting an
error. These numbers could be adjusted, or the limit could be removed.
Sorts the version array in descending order of version number to
improve the performance of check_vless_link() which stats every file
in the version array until it finds one linked to the versionless name
(which should be the highest version). Sorting, and tracking the
number of active entries, also allows for future optimization of other
operations that currently walk through the version array.
* futimens() appears more widely available than futimes() - so use it
* Rework caching of version array for files
While enumerating the entries in a directory is relatively fast,
on some systems (macOS) stat() of a file is slow.
While there is not general agreement on the name in the stat structure
of the timespec field for the modification time, POSIX specifies it
as "st_mtim", and it is possible to #define st_mtim to be the
system-specific name in "version.h" (macOS: st_mtimespec).
* FindHighestVersion can make use of sorted order of filename/version cache
Since the list of filename and versions is maintained in descending order
by version number (see get_version_array) the highest version is trivially
located at index 0 of the filename array.