Skip to content

Commit a247316

Browse files
committed
Fix #136
1 parent 02057e1 commit a247316

File tree

24 files changed

+673
-47
lines changed

24 files changed

+673
-47
lines changed
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2004, 2015 IBM Corporation and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* IBM Corporation - initial API and implementation
10+
*******************************************************************************/
11+
package ts.internal.io.tar;
12+
13+
// package org.eclipse.ui.internal.wizards.datatransfer;
14+
15+
/**
16+
* Representation of a file in a tar archive.
17+
*
18+
* @since 3.1
19+
*/
20+
public class TarEntry implements Cloneable
21+
{
22+
private String name;
23+
private long mode, time, size;
24+
private int type;
25+
int filepos;
26+
27+
/**
28+
* Entry type for normal files.
29+
*/
30+
public static final int FILE = '0';
31+
32+
/**
33+
* Entry type for directories.
34+
*/
35+
public static final int DIRECTORY = '5';
36+
37+
/**
38+
* Create a new TarEntry for a file of the given name at the
39+
* given position in the file.
40+
*
41+
* @param name filename
42+
* @param pos position in the file in bytes
43+
*/
44+
TarEntry(String name, int pos) {
45+
this.name = name;
46+
mode = 0644;
47+
type = FILE;
48+
filepos = pos;
49+
time = System.currentTimeMillis() / 1000;
50+
}
51+
52+
/**
53+
* Create a new TarEntry for a file of the given name.
54+
*
55+
* @param name filename
56+
*/
57+
public TarEntry(String name) {
58+
this(name, -1);
59+
}
60+
61+
/**
62+
* Returns the type of this file, one of FILE, LINK, SYM_LINK,
63+
* CHAR_DEVICE, BLOCK_DEVICE, DIRECTORY or FIFO.
64+
*
65+
* @return file type
66+
*/
67+
public int getFileType() {
68+
return type;
69+
}
70+
71+
/**
72+
* Returns the mode of the file in UNIX permissions format.
73+
*
74+
* @return file mode
75+
*/
76+
public long getMode() {
77+
return mode;
78+
}
79+
80+
/**
81+
* Returns the name of the file.
82+
*
83+
* @return filename
84+
*/
85+
public String getName() {
86+
return name;
87+
}
88+
89+
/**
90+
* Returns the size of the file in bytes.
91+
*
92+
* @return filesize
93+
*/
94+
public long getSize() {
95+
return size;
96+
}
97+
98+
/**
99+
* Returns the modification time of the file in seconds since January
100+
* 1st 1970.
101+
*
102+
* @return time
103+
*/
104+
public long getTime() {
105+
return time;
106+
}
107+
108+
/**
109+
* Sets the type of the file, one of FILE, LINK, SYMLINK, CHAR_DEVICE,
110+
* BLOCK_DEVICE, or DIRECTORY.
111+
*
112+
* @param type
113+
*/
114+
public void setFileType(int type) {
115+
this.type = type;
116+
}
117+
118+
/**
119+
* Sets the mode of the file in UNIX permissions format.
120+
*
121+
* @param mode
122+
*/
123+
public void setMode(long mode) {
124+
this.mode = mode;
125+
}
126+
127+
/**
128+
* Sets the size of the file in bytes.
129+
*
130+
* @param size
131+
*/
132+
public void setSize(long size) {
133+
this.size = size;
134+
}
135+
136+
/**
137+
* Sets the modification time of the file in seconds since January
138+
* 1st 1970.
139+
*
140+
* @param time
141+
*/
142+
public void setTime(long time) {
143+
this.time = time;
144+
}
145+
146+
public boolean isDirectory() {
147+
return type == DIRECTORY;
148+
}
149+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2004, 2015 IBM Corporation and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* IBM Corporation - initial API and implementation
10+
*******************************************************************************/
11+
package ts.internal.io.tar;
12+
// package org.eclipse.ui.internal.wizards.datatransfer;
13+
14+
/**
15+
* Exception generated upon encountering corrupted tar files.
16+
*/
17+
public class TarException extends Exception {
18+
/**
19+
* Generated serial version UID for this class.
20+
*/
21+
private static final long serialVersionUID = 2886671254518853528L;
22+
23+
/**
24+
* Constructs a TarException without a detail string.
25+
*/
26+
public TarException() {
27+
super();
28+
}
29+
30+
/**
31+
* Constructs a TarException with the specified detail string.
32+
*
33+
* @param s the detail string
34+
*/
35+
public TarException(String s) {
36+
super(s);
37+
}
38+
39+
/**
40+
* Constructs a TarException with the specified detail string.
41+
*
42+
* @param s the detail string
43+
* @param cause the cause
44+
*/
45+
public TarException(String s, Throwable cause) {
46+
super(s, cause);
47+
}
48+
}

0 commit comments

Comments
 (0)