2001-04-10 04:15:05 -07:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
2011-07-27 07:17:02 -07:00
|
|
|
/* OCaml */
|
2001-04-10 04:15:05 -07:00
|
|
|
/* */
|
|
|
|
/* File contributed by Lionel Fourquaux */
|
|
|
|
/* */
|
|
|
|
/* Copyright 2001 Institut National de Recherche en Informatique et */
|
|
|
|
/* en Automatique. All rights reserved. This file is distributed */
|
2001-12-07 05:41:02 -08:00
|
|
|
/* under the terms of the GNU Library General Public License, with */
|
|
|
|
/* the special exception on linking described in file ../../LICENSE. */
|
2001-04-10 04:15:05 -07:00
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
#include <mlvalues.h>
|
|
|
|
#include <fail.h>
|
2012-09-25 21:18:08 -07:00
|
|
|
#include "unixsupport.h"
|
|
|
|
#include <windows.h>
|
2010-01-22 04:48:24 -08:00
|
|
|
|
|
|
|
typedef
|
2001-04-10 04:15:05 -07:00
|
|
|
BOOL (WINAPI *tCreateHardLink)(
|
|
|
|
LPCTSTR lpFileName,
|
|
|
|
LPCTSTR lpExistingFileName,
|
2010-01-22 04:48:24 -08:00
|
|
|
LPSECURITY_ATTRIBUTES lpSecurityAttributes
|
2001-04-10 04:15:05 -07:00
|
|
|
);
|
2010-01-22 04:48:24 -08:00
|
|
|
|
2001-08-28 07:47:48 -07:00
|
|
|
CAMLprim value unix_link(value path1, value path2)
|
2010-01-22 04:48:24 -08:00
|
|
|
{
|
2001-04-10 04:15:05 -07:00
|
|
|
HMODULE hModKernel32;
|
2010-01-22 04:48:24 -08:00
|
|
|
tCreateHardLink pCreateHardLink;
|
2001-04-10 04:15:05 -07:00
|
|
|
hModKernel32 = GetModuleHandle("KERNEL32.DLL");
|
|
|
|
pCreateHardLink =
|
|
|
|
(tCreateHardLink) GetProcAddress(hModKernel32, "CreateHardLinkA");
|
|
|
|
if (pCreateHardLink == NULL)
|
|
|
|
invalid_argument("Unix.link not implemented");
|
|
|
|
if (! pCreateHardLink(String_val(path2), String_val(path1), NULL)) {
|
2001-08-28 07:47:48 -07:00
|
|
|
win32_maperr(GetLastError());
|
2001-04-10 04:15:05 -07:00
|
|
|
uerror("link", path2);
|
|
|
|
}
|
|
|
|
return Val_unit;
|
2010-01-22 04:48:24 -08:00
|
|
|
}
|