Jump to content

NTFS Links


Recommended Posts

Hello,

Is there any way to detect if a file is a link and copying the links as such (not copying 2 copies of the same data)? It seems very easy to tell if the folder is linked, but a file that is hardlinked seems to be totally unseen. I have a whole directory that has many linked files that i want to preserve these links and also preserve the space by using links and not copy the files. Any idea how to go about doing this?

Thanks,

Jon

Link to comment
Share on other sites

I am afraid I don't believe I am following. Is this what you mean?

FileCopy(@ScriptDir & "\link.lnk",@ScriptDir & "\Copied Links\link.lnk",8)

Maybe you didn't know what link files have a .lnk extension?

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

I am afraid I don't believe I am following. Is this what you mean?

FileCopy(@ScriptDir & "\link.lnk",@ScriptDir & "\Copied Links\link.lnk",8)

Maybe you didn't know what link files have a .lnk extension?

Nah, JonathanChan is refering to NTFS Links (HardLinks). Different to shortcut links.

(Hardlinked) Folders are Junctions and can be seen by DOS. Hardlinks are quite invisible to detection unless you can read the NTFS streams or the registry to where the information of being a link is recorded. This is why the help file points you to also installing NTFSLink, so you can atleast see and manage Hardlinks and Junctions through explorer. I'm not sure how to identify Hardlinks by using a script atm.

:whistle:

Edited by MHz
Link to comment
Share on other sites

I see, they are basically filesystem pointers and are analagous to pointers in memory.

I looked for a solution and I found this page:

http://msdn2.microsoft.com/en-us/library/ms810604.aspx

This was in the article I gave a link to above:

As the companion code for an old MIND article (see "Windows 2000 for Web Developers," MIND, March 1999), I provided a COM object allowing you to create hard links from script code. Code Sample 2 shows a VBScript program that utilizes it to create hard links for a given file. While it's easy to discover how many hard links a file has, there's no facility to enumerate them all. The API function GetFileInformationByHandle() fills out a BY_HANDLE_FILE_INFORMATION structure, whose nNumberOfLinks field informs you about that. Enumerating all the names of the linked files is a bit more difficult. Basically, you must scan the entire volume and, for each file, keep track of the unique ID it's been assigned. When you run into an existing ID you've found a hard link for that file. The file's unique ID is assigned by the system and is stored in the nFileIndexHigh and nFileIndexLow fields of BY_HANDLE_FILE_INFORMATION.

The function GetFileInformationByHandle()

http://msdn2.microsoft.com/en-us/library/aa364952.aspx

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...