MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / ExtractHardlink

Function ExtractHardlink

Libraries/unrar/hardlinks.cpp:1–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1bool ExtractHardlink(wchar *NameNew,wchar *NameExisting,size_t NameExistingSize)
2{
3 SlashToNative(NameExisting,NameExisting,NameExistingSize); // Not needed for RAR 5.1+ archives.
4
5 if (!FileExist(NameExisting))
6 {
7 uiMsg(UIERROR_HLINKCREATE,NameNew);
8 uiMsg(UIERROR_NOLINKTARGET);
9 ErrHandler.SetErrorCode(RARX_CREATE);
10 return false;
11 }
12 CreatePath(NameNew,true);
13
14#ifdef _WIN_ALL
15 bool Success=CreateHardLink(NameNew,NameExisting,NULL)!=0;
16 if (!Success)
17 {
18 uiMsg(UIERROR_HLINKCREATE,NameNew);
19 ErrHandler.SysErrMsg();
20 ErrHandler.SetErrorCode(RARX_CREATE);
21 }
22 return Success;
23#elif defined(_UNIX)
24 char NameExistingA[NM],NameNewA[NM];
25 WideToChar(NameExisting,NameExistingA,ASIZE(NameExistingA));
26 WideToChar(NameNew,NameNewA,ASIZE(NameNewA));
27 bool Success=link(NameExistingA,NameNewA)==0;
28 if (!Success)
29 {
30 uiMsg(UIERROR_HLINKCREATE,NameNew);
31 ErrHandler.SysErrMsg();
32 ErrHandler.SetErrorCode(RARX_CREATE);
33 }
34 return Success;
35#else
36 return false;
37#endif
38}
39

Callers 1

ExtractCurrentFileMethod · 0.85

Calls 7

SlashToNativeFunction · 0.85
FileExistFunction · 0.85
uiMsgFunction · 0.85
CreatePathFunction · 0.85
WideToCharFunction · 0.85
SetErrorCodeMethod · 0.80
SysErrMsgMethod · 0.80

Tested by

no test coverage detected