X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Flink.c;h=1b0fe0a0e96110ae50bf028cc67814f290d27b02;hb=fa6f00004c5ea9f4b341a7c60db177a7419f06aa;hp=42d086ce88788b4844b1ea97be38b25bcbdcf62d;hpb=a115e247aac5bab8a0ca11d544abd149dfeb3f21;p=gnulib.git diff --git a/lib/link.c b/lib/link.c index 42d086ce8..1b0fe0a0e 100644 --- a/lib/link.c +++ b/lib/link.c @@ -1,6 +1,6 @@ /* Emulate link on platforms that lack it, namely native Windows platforms. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2011 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,19 +33,19 @@ /* CreateHardLink was introduced only in Windows 2000. */ typedef BOOL (WINAPI * CreateHardLinkFuncType) (LPCTSTR lpFileName, - LPCTSTR lpExistingFileName, - LPSECURITY_ATTRIBUTES lpSecurityAttributes); + LPCTSTR lpExistingFileName, + LPSECURITY_ATTRIBUTES lpSecurityAttributes); static CreateHardLinkFuncType CreateHardLinkFunc = NULL; static BOOL initialized = FALSE; static void initialize (void) { - HMODULE kernel32 = LoadLibrary ("kernel32.dll"); + HMODULE kernel32 = GetModuleHandle ("kernel32.dll"); if (kernel32 != NULL) { CreateHardLinkFunc = - (CreateHardLinkFuncType) GetProcAddress (kernel32, "CreateHardLinkA"); + (CreateHardLinkFuncType) GetProcAddress (kernel32, "CreateHardLinkA"); } initialized = TRUE; } @@ -103,39 +103,39 @@ link (const char *file1, const char *file2) * system. */ DWORD err = GetLastError (); switch (err) - { - case ERROR_ACCESS_DENIED: - errno = EACCES; - break; - - case ERROR_INVALID_FUNCTION: /* fs does not support hard links */ - errno = EPERM; - break; - - case ERROR_NOT_SAME_DEVICE: - errno = EXDEV; - break; - - case ERROR_PATH_NOT_FOUND: - case ERROR_FILE_NOT_FOUND: - errno = ENOENT; - break; - - case ERROR_INVALID_PARAMETER: - errno = ENAMETOOLONG; - break; - - case ERROR_TOO_MANY_LINKS: - errno = EMLINK; - break; - - case ERROR_ALREADY_EXISTS: - errno = EEXIST; - break; - - default: - errno = EIO; - } + { + case ERROR_ACCESS_DENIED: + errno = EACCES; + break; + + case ERROR_INVALID_FUNCTION: /* fs does not support hard links */ + errno = EPERM; + break; + + case ERROR_NOT_SAME_DEVICE: + errno = EXDEV; + break; + + case ERROR_PATH_NOT_FOUND: + case ERROR_FILE_NOT_FOUND: + errno = ENOENT; + break; + + case ERROR_INVALID_PARAMETER: + errno = ENAMETOOLONG; + break; + + case ERROR_TOO_MANY_LINKS: + errno = EMLINK; + break; + + case ERROR_ALREADY_EXISTS: + errno = EEXIST; + break; + + default: + errno = EIO; + } return -1; }