Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7882787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:22:04+00:00 2026-06-03T04:22:04+00:00

I’ve been playing with hard links lately on a program that copies files all

  • 0

I’ve been playing with hard links lately on a program that copies files all over the place in its directory, deleting all the duplicates and replacing them with hard links. I got that down okay. I understand in the way hard links work that it is just another reference to the data itself on disk. So if I were to access the data from a created hard link, it would look the same.

The problem is finding the real amount of disk space used, which is one of the problems in verifying this is indeed saving space. In other words, if one were to start with a 12K file, create a hard link of that file, then select both in Explorer, it would show as 24K used on disk, not 12K as it really should be.

I know I can query the free space on the disk before and after the process and then compare. But that’s an initial assessment, which is hard to verify after the fact. I know as well that I can use GetFileInformationByHandle to find out whether the file in question has multiple references.

So any ideas here? Would I have to call GetFileInformationByHandle for each file, logging all that data, and then remove the files that have duplicate index references to get an accurate view of how much disk space is actually being used? Or is there an easier way to accomplish this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:22:05+00:00Added an answer on June 3, 2026 at 4:22 am

    Do exactly that. Maintain a set of (dwVolumeSerialNumber, nFileIndexHigh, nFileIndexLow) triples. Each time you encounter a file, check whether you’ve seen it before (i.e., whether its triple is already in your set). If so, then skip it. If not, then add its file size to your total and insert its information into the set.

    This unfortunately means you’ll have to open every file. The link count isn’t kept in the directory information, so FindFirstFile can’t give it to you. You need GetFileInformationByHandle, and that requires a handle.

    You might wish to read Raymond Chen’s article on the topic; it mentions several more corner cases besides hard links that could apply to your application, including reparse points, cluster rounding, and alternate data streams.

    You could try to reduce the effort required in maintaining the set by only tracking files that have link counts greater than 1. Files with only one link shouldn’t appear multiple times in your directory traversal. That assumes you’ll only see each directory exactly once. Reparse points and junctions can make the assumption invalid, so if you try to reduce the size of your “files seen” set, you’ll need to also keep track of which directories you’ve already seen.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
I have a French site that I want to parse, but am running into
I have a text area in my form which accepts all possible characters from
I need a function that will clean a strings' special characters. I do NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.