20 July 2016

Hard link facility in ExpPrint

With the release of ExpPrint 6.3 it now has the ability to identify hard linked files.

A key point to know about the operating system’s implementation of hard links is that there isn’t really an original file with others that link to it.

There’s a good explanation of hard links on Wikipedia here, but in brief, the idea that a file is contained insider a folder isn’t the full story…

A file’s data exists on a disk, and a folder contains references that link to the data on the disk. It’s these references inside a folder that we normally think of as the file. The file data isn’t contained in a folder, there’s just a link with the file’s name to the data. Every file is a hard link, but it’s when more than 1 file links to the same data that we tend to think of those other file items as links.

With that understanding you’ll appreciate that each file involved in a multiply linked file is equal and indistinguishable, other than its name. Consequently, although ExpPrint identifies one occurrence of a hard link as being the original and others as links, it’s just a way of identifying multiple links to one item. If you’re the person who created the original file and the hard links, you may think of them differently to how ExpPrint identifies them, which is as it encounters them in a folder hierarchy. However, ExpPrint has the flexibility in its HTML listings to show the hard link information in several ways which I’ll detail later.

What ExpPrint does..

When you create a listing with the "Identify hard linked files" option set (in the Additional Settings dialog), ExpPrint records the full path for the first occurrence it encounters of a file that has multiple links. If it subsequently encounters another file linked to the same one, it copies the full path name of the first occurrence. Consequently, the .xplisting file contains an “HLName” attribute for any file that has more than 1 link. The first encountered file has the full path name of itself in that attribute value, and any files that link to the same file have the attribute value of the first encountered file.

So, if you have the following arrangement and create a listing of Folder A that includes Folder B:

Folder A
|   File A
\---Folder B
        File B

… and File A and File B are links to the same (file) data.

In the .xplisting file, ExpPrint will record:

File A with a “HLName” attribute value of “Folder A\File A”

File B with a “HLName” attribute value of “Folder A\File A”

Note that ExpPrint only finds hard links for files it encounters when creating a listing.

Because hard links can only be created on the same disk volume, if you create an ExpPrint listing for an entire disk drive (and there are no permission restrictions), then ExpPrint can identify all hard links. If you create a listing of a sub-folder, or of a disk drive and limit the folder depth, then ExpPrint will only identify hard links for files within the listing scope.


.xplisting (XML) to HTML conversion

In the conversion to HTML, the first hard link file item (inside a table <tr> element) is given the class name "HardLinkOrig", and any other occurrences are given the class name "HardLink". These names enable easy styling to be applied to each.


Hard Link Styles

There are currently 4 style sheets applicable to hard links:

Style Name

“Hard Links -”


'Linked With' Prefix

Prefixes the Hard Link Path column contents of linked files with the bold text “Linked With” to clarify the path is to the original file that ExpPrint encountered.

Root Linked Item

Replaces the Hard Link Path column text with the fixed text “Root Linked Item” to make it clear that this is what ExpPrint is considering to be the original file.

Size (N-A Faint)

Prefixes the size column of hard linked files with “n/a” and also greys the text to indicate that the size of linked files are not accumulated in the folder total size.

[hl] Text Indicator

Adds blue text “hl” to the Indicator column for all hard link files.

Since none of these styles interact, you can apply them all together like this:


The above image shows 2 files that are hard linked, the first “hl1" is shown as the original item and the second “temp" is shown as a link to “hl1".

The “’Linked With’ Prefix” style prefixes that text on the “temp” file’s listing.

The “Root Linked Item” style replaces the hard link column text of file “hl1”, which would otherwise show the full path to hl1, with the text “Root Linked Item”.

The “Size (N-A Faint)” style modifies the Size column of the “temp” file’s listing.

The “[hl] Text Indicator” style shows the blue “hl” text in the indicator column for both files.


There’s not much more to say other than when you create a listing with the "Identify hard linked files" option set, ExpPrint only totals hard linked files once, so in the above example, parent folder totals to the folder containing the file named “temp” will not include the size of temp – because they’re totalled for in the hl1 file’s folder.

If you have any further questions about this facility or any others on any of our products, don’t hesitate to ask via email.

No comments:

Post a Comment