Holy cow, I wrote a book!
One might think that computing the size of a directory would be
a simple matter of adding up the sizes of all the files in it.
Oh if it were only that simple.
There are many things that make computing the size of a directory
difficult, some of which even throw into doubt the even existence
of the concept "size of a directory".
If you're computing the size in order to show the user how much disk space
they will gain by deleting the directory, then you do or don't,
depending on how you're going to delete the reparse point.
If you're computing the size in preparation for copying,
then you probably do. Or maybe you don't - should the copy merely
copy the reparse point instead of tunneling through it?
What do you if the user doesn't have permission to create
reparse points? Or if the destination doesn't support reparse points?
Or if the user is creating a copy because they are making a back-up?
Dividing the "weight" of the file among its hard links avoids
double-counting (or higher), so that when all the hard links are
found, the file's total size is correctly accounted for.
And it represents the concept that all the hard links to a file
"share the cost" of the resources the file consumes.
But what if you don't find all the hard links?
It it correct that the file was undercounted?
[Minor typo fixed, 12pm]
If you're copying a file and you discover that it has multiple
hard links, what do you do? Do you break the links in the copy?
Do you attempt to reconstruct them? What if the destination doesn't
support hard links?
When adding up the size of the files in a directory, do you
add up the logical size or the physical size? If you're
computing the size in preparation for copying, then you probably
want the logical size, but if you're computing to see how much
disk space would be freed up by deleting it, then you probably
want physical size.
But if you're computing for copying and the copy destination
supports compression, do you want to use the physical size
after all? Now you're assuming that the source and destination
compression algorithms are comparable.
There is no single answer to all of the above questions.
You have to consider each one, apply it to your situation,
and decide which way you want to go.
(And copying a directory tree is even scarier.
What do you do with the ACLs? Do you copy them too?
Do you preserve the creation date?
It all depends on why you're copying the tree.)