| 1 | |
| 2 | |
| 3 | static 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 | |
| 42 | static bool IsFullPath(const char *PathA) // Unix ASCII version. |
no test coverage detected