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

Function UnixSymlink

Libraries/unrar/ulinks.cpp:3–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1
2
3static bool UnixSymlink(const char *Target,const wchar *LinkName,RarTime *ftm,RarTime *fta)
4{
5 CreatePath(LinkName,true);
6 DelFile(LinkName);
7 char LinkNameA[NM];
8 WideToChar(LinkName,LinkNameA,ASIZE(LinkNameA));
9 if (symlink(Target,LinkNameA)==-1) // Error.
10 {
11 if (errno==EEXIST)
12 uiMsg(UIERROR_ULINKEXIST,LinkName);
13 else
14 {
15 uiMsg(UIERROR_SLINKCREATE,UINULL,LinkName);
16 ErrHandler.SetErrorCode(RARX_WARNING);
17 }
18 return false;
19 }
20#ifdef USE_LUTIMES
21#ifdef UNIX_TIME_NS
22 timespec times[2];
23 times[0].tv_sec=fta->GetUnix();
24 times[0].tv_nsec=fta->IsSet() ? long(fta->GetUnixNS()%1000000000) : UTIME_NOW;
25 times[1].tv_sec=ftm->GetUnix();
26 times[1].tv_nsec=ftm->IsSet() ? long(ftm->GetUnixNS()%1000000000) : UTIME_NOW;
27 utimensat(AT_FDCWD,LinkNameA,times,AT_SYMLINK_NOFOLLOW);
28#else
29 struct timeval tv[2];
30 tv[0].tv_sec=fta->GetUnix();
31 tv[0].tv_usec=long(fta->GetUnixNS()%1000000000/1000);
32 tv[1].tv_sec=ftm->GetUnix();
33 tv[1].tv_usec=long(ftm->GetUnixNS()%1000000000/1000);
34 lutimes(LinkNameA,tv);
35#endif
36#endif
37
38 return true;
39}
40
41
42static bool IsFullPath(const char *PathA) // Unix ASCII version.

Callers 2

ExtractUnixLink30Function · 0.85
ExtractUnixLink50Function · 0.85

Calls 8

CreatePathFunction · 0.85
DelFileFunction · 0.85
WideToCharFunction · 0.85
uiMsgFunction · 0.85
SetErrorCodeMethod · 0.80
GetUnixMethod · 0.80
GetUnixNSMethod · 0.80
IsSetMethod · 0.45

Tested by

no test coverage detected