Example #1
0
size_t Archive::ReadCommentData(Array<byte> *CmtData,Array<wchar> *CmtDataW)
{
  bool Unicode=SubHead.SubFlags & SUBHEAD_FLAGS_CMT_UNICODE;
  if (!ReadSubData(CmtData,NULL))
    return(0);
  size_t CmtSize=CmtData->Size();
  if (Unicode)
  {
    CmtSize/=2;
    Array<wchar> DataW(CmtSize+1);
    RawToWide(CmtData->Addr(),DataW.Addr(),CmtSize);
    DataW[CmtSize]=0;
    size_t DestSize=CmtSize*4;
    CmtData->Alloc(DestSize+1);
    WideToChar(DataW.Addr(),(char *)CmtData->Addr(),DestSize);
    (*CmtData)[DestSize]=0;
    CmtSize=strlen((char *)CmtData->Addr());
    CmtData->Alloc(CmtSize);
    if (CmtDataW!=NULL)
    {
      *CmtDataW=DataW;
      CmtDataW->Alloc(CmtSize);
    }
  }
  else
    if (CmtDataW!=NULL)
    {
      CmtData->Push(0);
      CmtDataW->Alloc(CmtSize+1);
      CharToWide((char *)CmtData->Addr(),CmtDataW->Addr(),CmtSize+1);
      CmtData->Alloc(CmtSize);
      CmtDataW->Alloc(wcslen(CmtDataW->Addr()));
    }
  return(CmtSize);
}
Example #2
0
int Archive::ReadCommentData(Array<byte> &CmtData)
{
  bool Unicode=SubHead.SubFlags & SUBHEAD_FLAGS_CMT_UNICODE;
  if (!ReadSubData(&CmtData,NULL))
    return(0);
  int CmtSize=CmtData.Size();
  if (Unicode)
  {
    CmtSize/=2;
    Array<wchar> CmtDataW(CmtSize+1);
    RawToWide(&CmtData[0],&CmtDataW[0],CmtSize);
    CmtDataW[CmtSize]=0;
    CmtData.Alloc(CmtSize*2);
    WideToChar(&CmtDataW[0],(char *)&CmtData[0]);
    CmtSize=strlen((char *)&CmtData[0]);
    CmtData.Alloc(CmtSize);
  }
  return(CmtSize);
}
Example #3
0
bool Archive::ReadCommentData(Array<wchar> *CmtData)
{
  Array<byte> CmtRaw;
  if (!ReadSubData(&CmtRaw,NULL))
    return false;
  size_t CmtSize=CmtRaw.Size();
  CmtRaw.Push(0);
  CmtData->Alloc(CmtSize+1);
  if (Format==RARFMT50)
    UtfToWide((char *)&CmtRaw[0],CmtData->Addr(0),CmtData->Size());
  else
    if ((SubHead.SubFlags & SUBHEAD_FLAGS_CMT_UNICODE)!=0)
    {
      RawToWide(&CmtRaw[0],CmtData->Addr(0),CmtSize/2);
      (*CmtData)[CmtSize/2]=0;

    }
    else
    {
      CharToWide((char *)&CmtRaw[0],CmtData->Addr(0),CmtData->Size());
    }
  CmtData->Alloc(wcslen(CmtData->Addr(0))); // Set buffer size to actual comment length.
  return true;
}