Unix to Windows Porting Dictionary for HPC

RSS

Links

Function List

link


Unix

header file: unistd.h

int link(const char *path1, const char *path2);

Windows

header file: Windows.h

BOOL WINAPI CreateHardLink( __in LPCTSTR lpFileName, 
                            __in LPCTSTR lpExistingFileName, 
                            __reserved LPSECURITY_ATTRIBUTES lpSecurityAttributes);

Purpose

The link() function creates a new link path2 for the existing file path1. The Windows function CreateHardLink provides similar functionality, but with slightly different syntax. For full details, see the MSDN article.

Discussion

The CreateHardLink is a C++ function and requires Windows 2000 Professional, Windows 2000 Server, or above. Additionally, CreateHardLink is only supported when using the NTFS filesystem.

Example of Use in Windows

#include <windows.h>

BOOL fCreatedLink = CreateHardLink(pszNewLinkName, 
                                   pszExistingFileName, 
                                   NULL // reserved, must be NULL
                                  ); 

if ( fCreatedLink == FALSE ) {
;// handle error condition
}

  
blog comments powered by Disqus
Valid HTML 4.01 Transitional Valid CSS!