summaryrefslogtreecommitdiff
path: root/org.fox.ttcomics/src/main/java/org/fox/ttcomics2/junrar/rarfile/UnixOwnersHeader.java
blob: 8cc237a4d94881053681f11c009b891e5a788c3d (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
66
67
68
69
70
71
72
package org.fox.ttcomics2.junrar.rarfile;


import org.fox.ttcomics2.junrar.io.Raw;


public class UnixOwnersHeader
        extends SubBlockHeader {
    private int ownerNameSize;
    private int groupNameSize;
    private String owner;
    private String group;

    public UnixOwnersHeader(SubBlockHeader sb, byte[] uoHeader) {
        super(sb);
        int pos = 0;
        ownerNameSize = Raw.readShortLittleEndian(uoHeader, pos) & 0xFFFF;
        pos += 2;
        groupNameSize = Raw.readShortLittleEndian(uoHeader, pos) & 0xFFFF;
        pos += 2;
        if (pos + ownerNameSize < uoHeader.length) {
            byte[] ownerBuffer = new byte[ownerNameSize];
            System.arraycopy(uoHeader, pos, ownerBuffer, 0, ownerNameSize);
            owner = new String(ownerBuffer);
        }
        pos += ownerNameSize;
        if (pos + groupNameSize < uoHeader.length) {
            byte[] groupBuffer = new byte[groupNameSize];
            System.arraycopy(uoHeader, pos, groupBuffer, 0, groupNameSize);
            group = new String(groupBuffer);
        }
    }

    public String getGroup() {
        return group;
    }

    public void setGroup(String group) {
        this.group = group;
    }

    public int getGroupNameSize() {
        return groupNameSize;
    }

    public void setGroupNameSize(int groupNameSize) {
        this.groupNameSize = groupNameSize;
    }

    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    public int getOwnerNameSize() {
        return ownerNameSize;
    }

    public void setOwnerNameSize(int ownerNameSize) {
        this.ownerNameSize = ownerNameSize;
    }

    /* (non-Javadoc)
     * @see de.innosystec.unrar.rarfile.SubBlockHeader#print()
     */
    public void print() {
        super.print();
    }
}