Пример #1
0
// Used for archives created by old RAR versions up to and including RAR 2.9.
// New RAR versions store file comments in separate headers and such comments
// are displayed in ListNewSubHeader function.
void Archive::ViewFileComment()
{
    if (!(NewLhd.Flags & LHD_COMMENT) || Cmd->DisableComment || OldFormat)
        return;

#ifndef GUI
    mprintf(St(MFileComment));
#endif
    const int MaxSize = 0x8000;
    Array<char> CmtBuf(MaxSize);
    SaveFilePos SavePos(*this);
    Seek(CurBlockPos + SIZEOF_NEWLHD + NewLhd.NameSize, SEEK_SET);
    int64 SaveCurBlockPos = CurBlockPos;
    int64 SaveNextBlockPos = NextBlockPos;
    size_t Size = ReadHeader();
    CurBlockPos = SaveCurBlockPos;
    NextBlockPos = SaveNextBlockPos;

    if (Size < 7 || CommHead.HeadType != COMM_HEAD)
        return;

    if (CommHead.HeadCRC != HeaderCRC)
    {
#ifndef GUI
        Log(FileName, St(MLogCommHead));
#endif
        return;
    }

    if (CommHead.UnpVer < 15 || CommHead.UnpVer > UNP_VER ||
            CommHead.Method > 0x30 || CommHead.UnpSize > MaxSize)
        return;

    Read(&CmtBuf[0], CommHead.UnpSize);

    if (CommHead.CommCRC != ((~CRC(0xffffffff, &CmtBuf[0], CommHead.UnpSize) & 0xffff)))
    {
        Log(FileName, St(MLogBrokFCmt));
    }

    else
    {
        OutComment(&CmtBuf[0], CommHead.UnpSize);
#ifndef GUI
        mprintf("\n");
#endif
    }
}
Пример #2
0
void Archive::ViewComment()
{
#ifndef GUI
  if (Cmd->DisableComment)
    return;
  Array<byte> CmtBuf;
  if (GetComment(&CmtBuf,NULL))
  {
    size_t CmtSize=CmtBuf.Size();
    char *ChPtr=(char *)memchr(&CmtBuf[0],0x1A,CmtSize);
    if (ChPtr!=NULL)
      CmtSize=ChPtr-(char *)&CmtBuf[0];
    mprintf("\n");
    OutComment((char *)&CmtBuf[0],CmtSize);
  }
#endif
}
Пример #3
0
void Archive::ViewComment()
{
#ifndef GUI
  if (Cmd->DisableComment)
    return;
  Array<wchar> CmtBuf;
  if (GetComment(&CmtBuf))
  {
    size_t CmtSize=CmtBuf.Size();
    wchar *ChPtr=wcschr(&CmtBuf[0],0x1A);
    if (ChPtr!=NULL)
      CmtSize=ChPtr-&CmtBuf[0];
    mprintf(L"\n");
    OutComment(&CmtBuf[0],CmtSize);
  }
#endif
}