File: CabItem.h

package info (click to toggle)
p7zip 16.02%2Bdfsg-3%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 14,112 kB
  • sloc: cpp: 167,145; ansic: 14,992; python: 1,911; asm: 1,688; sh: 1,132; makefile: 701
file content (66 lines) | stat: -rw-r--r-- 1,522 bytes parent folder | download | duplicates (8)
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
66
// Archive/CabItem.h

#ifndef __ARCHIVE_CAB_ITEM_H
#define __ARCHIVE_CAB_ITEM_H

#include "../../../Common/MyString.h"

#include "CabHeader.h"

namespace NArchive {
namespace NCab {

const unsigned kNumMethodsMax = 16;

struct CFolder
{
  UInt32 DataStart; // offset of the first CFDATA block in this folder
  UInt16 NumDataBlocks; // number of CFDATA blocks in this folder
  Byte MethodMajor;
  Byte MethodMinor;
  
  Byte GetMethod() const { return (Byte)(MethodMajor & 0xF); }
};

struct CItem
{
  AString Name;
  UInt32 Offset;
  UInt32 Size;
  UInt32 Time;
  UInt32 FolderIndex;
  UInt16 Flags;
  UInt16 Attributes;
  
  UInt64 GetEndOffset() const { return (UInt64)Offset + Size; }
  UInt32 GetWinAttrib() const { return (UInt32)Attributes & ~(UInt32)NHeader::kFileNameIsUtf8_Mask; }
  bool IsNameUTF() const { return (Attributes & NHeader::kFileNameIsUtf8_Mask) != 0; }
  bool IsDir() const { return (Attributes & FILE_ATTRIBUTE_DIRECTORY) != 0; }

  bool ContinuedFromPrev() const
  {
    return
      FolderIndex == NHeader::NFolderIndex::kContinuedFromPrev ||
      FolderIndex == NHeader::NFolderIndex::kContinuedPrevAndNext;
  }
  
  bool ContinuedToNext() const
  {
    return
      FolderIndex == NHeader::NFolderIndex::kContinuedToNext ||
      FolderIndex == NHeader::NFolderIndex::kContinuedPrevAndNext;
  }

  int GetFolderIndex(unsigned numFolders) const
  {
    if (ContinuedFromPrev())
      return 0;
    if (ContinuedToNext())
      return numFolders - 1;
    return FolderIndex;
  }
};

}}

#endif