Bool System::CreateHardLink( const GChar * strPathName, const GChar * strTargetPathName ) const { #if ( defined(UNICODE) || defined (_UNICODE) ) BOOL bRes = CreateHardLinkW( strPathName, strTargetPathName, NULL ); #else BOOL bRes = CreateHardLinkA( strPathName, strTargetPathName, NULL ); #endif return ( bRes != FALSE ); }
posix_errno_t efile_make_hard_link(const efile_path_t *existing_path, const efile_path_t *new_path) { ASSERT_PATH_FORMAT(existing_path); ASSERT_PATH_FORMAT(new_path); if(!CreateHardLinkW((WCHAR*)new_path->data, (WCHAR*)existing_path->data, NULL)) { return windows_to_posix_errno(GetLastError()); } return 0; }
CAMLprim value win_link(value path1, value wpath1, value wpath2) { CAMLparam3(path1, wpath1, wpath2); if (!CreateHardLinkW((LPWSTR)String_val(wpath2), (LPWSTR)String_val(wpath1), NULL)) { win32_maperr (GetLastError ()); uerror("rename", path1); } CAMLreturn (Val_unit); }
BOOL My_CreateHardLinkW() { LPCWSTR lpFileName=NULL; LPCWSTR lpExistingFileName=NULL; LPSECURITY_ATTRIBUTES lpSecurityAttributes=NULL; BOOL returnVal_Real = NULL; BOOL returnVal_Intercepted = NULL; DWORD error_Real = 0; DWORD error_Intercepted = 0; __try{ disableInterception(); returnVal_Real = CreateHardLinkW (lpFileName,lpExistingFileName,lpSecurityAttributes); error_Real = GetLastError(); enableInterception(); returnVal_Intercepted = CreateHardLinkW (lpFileName,lpExistingFileName,lpSecurityAttributes); error_Intercepted = GetLastError(); }__except(puts("in filter"), 1){puts("exception caught");} return ((returnVal_Real == returnVal_Intercepted) && (error_Real == error_Intercepted)); }
bool os_create_hardlink(const std::wstring &linkname, const std::wstring &fname, bool use_ioref, bool* too_many_links) { BOOL r=CreateHardLinkW(linkname.c_str(), fname.c_str(), NULL); if(too_many_links!=NULL) { *too_many_links=false; if(!r) { int err=GetLastError(); if(err==ERROR_TOO_MANY_LINKS) { *too_many_links=true; } } } return r!=0; }
static bool create_hardlink (const char * dst_path, const char * src_path) { #ifndef _WIN32 return link (src_path, dst_path) != -1; #else wchar_t * wide_src_path = tr_win32_utf8_to_native (src_path, -1); wchar_t * wide_dst_path = tr_win32_utf8_to_native (dst_path, -1); bool ret = CreateHardLinkW (wide_dst_path, wide_src_path, NULL); tr_free (wide_dst_path); tr_free (wide_src_path); return ret; #endif }
bool os_create_hardlink(const std::string &linkname, const std::string &fname, bool use_ioref, bool* too_many_links) { if (use_ioref) { return os_create_reflink(linkname, fname); } BOOL r=CreateHardLinkW(ConvertToWchar(linkname).c_str(), ConvertToWchar(fname).c_str(), NULL); if(too_many_links!=NULL) { *too_many_links=false; if(!r) { int err=GetLastError(); if(err==ERROR_TOO_MANY_LINKS) { *too_many_links=true; } } } return r!=0; }