patch to enable both hard and symbolic linking on win32

Blaine Whittle <>
Tue Oct 5 00:39:53 CEST 2010

This patch adds support for both hard and symbolic linking for Windows.

This patch is a resubmission via a patch originally submitted on 9/2/2009 by Alex Tearse-Doyle.

Hard linking requires XP or later and a NTFS formatted drive.

Symbolic linking on Windows requires either Windows Vista, Windows Server 2008, or Windows 7.   The Windows API call for creating symbolic links is dynamically executed via LoadLibrary, which allows a single binary to handle both the OS supported and OS not-supported cases.    For example calling file:make_symlink on a Windows XP will return {error, enotsup}, however the same call should work as expected on Windows Vista.

All the file module functions are supported:  make_link/2, make_sym_link/2, read_link/1 and read_link_info/1.  Code has been added so that read_info/1 could return the number of hard links on the file.  However, this code has been commented out as it severally affects the performance of read_info/1 on windows.   We left the code in the patch to allow anyone to enable this feature if needed.

On a side note, the file.erl man page, {error, exdev} isn't listed on file's man page as a valid return type for make_link, however the error is (correctly) returned when attempting to create a hard link to file on another volume (which should result in {error, exdev}).

Patch is located at git fetch git:// win32_file_linking

More information about the erlang-patches mailing list