Welcome to mirror list, hosted at ThFree Co, Russian Federation.

GZipOut.cpp « GZip « Archive « 7zip « CPP - github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3d0d4f7a020950f1431c0afd3fe672b45b6a2f11 (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Archive/GZipOut.cpp

#include "StdAfx.h"

#include "GZipOut.h"

#include "Windows/Defs.h"
#include "../../Common/StreamUtils.h"

namespace NArchive {
namespace NGZip {

HRESULT COutArchive::WriteBytes(const void *buffer, UInt32 size)
{
  return WriteStream(m_Stream, buffer, size);
}

HRESULT COutArchive::WriteByte(Byte value)
{
  return WriteBytes(&value, 1);
}

HRESULT COutArchive::WriteUInt16(UInt16 value)
{
  for (int i = 0; i < 2; i++)
  {
    RINOK(WriteByte((Byte)value));
    value >>= 8;
  }
  return S_OK;
}

HRESULT COutArchive::WriteUInt32(UInt32 value)
{
  for (int i = 0; i < 4; i++)
  {
    RINOK(WriteByte((Byte)value));
    value >>= 8;
  }
  return S_OK;
}

HRESULT COutArchive::WriteHeader(const CItem &item)
{
  RINOK(WriteUInt16(kSignature));
  RINOK(WriteByte(item.CompressionMethod));
  RINOK(WriteByte((Byte)(item.Flags & NFileHeader::NFlags::kNameIsPresent)));
  RINOK(WriteUInt32(item.Time));
  RINOK(WriteByte(item.ExtraFlags));
  RINOK(WriteByte(item.HostOS));
  if (item.NameIsPresent())
  {
    RINOK(WriteBytes((const char *)item.Name, item.Name.Length()));
    RINOK(WriteByte(0));
  }
  return S_OK;
}

HRESULT COutArchive::WritePostHeader(const CItem &item)
{
  RINOK(WriteUInt32(item.FileCRC));
  return WriteUInt32(item.UnPackSize32);
}

}}