1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include "rar.hpp"
#include "Util.h"
#include "utils/URIUtils.h"
int ExtractLink(ComprDataIO &DataIO,Archive &Arc,char *DestName,uint &LinkCRC,bool Create)
{
#if defined(SAVE_LINKS) && defined(_UNIX)
char FileName[NM];
if (IsLink(Arc.NewLhd.FileAttr))
{
uint DataSize=Min(Arc.NewLhd.PackSize,sizeof(FileName)-1);
DataIO.UnpRead((byte *)FileName,DataSize);
FileName[DataSize]=0;
if (Create)
{
CStdString strPath;
URIUtils::GetDirectory(DestName,strPath);
CUtil::CreateDirectoryEx(strPath);
if (symlink(FileName,DestName)==-1)
{
if (errno==EEXIST)
Log(Arc.FileName,St(MSymLinkExists),DestName);
else
{
Log(Arc.FileName,St(MErrCreateLnk),DestName);
ErrHandler.SetErrorCode(WARNING);
}
}
}
int NameSize=Min(DataSize,strlen(FileName));
LinkCRC=CRC(0xffffffff,FileName,NameSize); return(1);
}
#endif
return(0);
}
|