KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > wizards > datatransfer > TarEntry


1 /*******************************************************************************
2  * Copyright (c) 2004, 2006 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 org.eclipse.ui.internal.wizards.datatransfer;
12
13 /**
14  * Representation of a file in a tar archive.
15  *
16  * @since 3.1
17  */

18 public class TarEntry implements Cloneable JavaDoc
19 {
20     private String JavaDoc name;
21     private long mode, time, size;
22     private int type;
23     int filepos;
24
25     /**
26      * Entry type for normal files.
27      */

28     public static final int FILE = '0';
29
30     /**
31      * Entry type for directories.
32      */

33     public static final int DIRECTORY = '5';
34     
35     /**
36      * Create a new TarEntry for a file of the given name at the
37      * given position in the file.
38      *
39      * @param name filename
40      * @param pos position in the file in bytes
41      */

42     TarEntry(String JavaDoc name, int pos) {
43         this.name = name;
44         mode = 0644;
45         type = FILE;
46         filepos = pos;
47         time = System.currentTimeMillis() / 1000;
48     }
49
50     /**
51      * Create a new TarEntry for a file of the given name.
52      *
53      * @param name filename
54      */

55     public TarEntry(String JavaDoc name) {
56         this(name, -1);
57     }
58
59     /**
60      * Returns the type of this file, one of FILE, LINK, SYM_LINK,
61      * CHAR_DEVICE, BLOCK_DEVICE, DIRECTORY or FIFO.
62      *
63      * @return file type
64      */

65     public int getFileType() {
66         return type;
67     }
68
69     /**
70      * Returns the mode of the file in UNIX permissions format.
71      *
72      * @return file mode
73      */

74     public long getMode() {
75         return mode;
76     }
77
78     /**
79      * Returns the name of the file.
80      *
81      * @return filename
82      */

83     public String JavaDoc getName() {
84         return name;
85     }
86
87     /**
88      * Returns the size of the file in bytes.
89      *
90      * @return filesize
91      */

92     public long getSize() {
93         return size;
94     }
95
96     /**
97      * Returns the modification time of the file in seconds since January
98      * 1st 1970.
99      *
100      * @return time
101      */

102     public long getTime() {
103         return time;
104     }
105
106     /**
107      * Sets the type of the file, one of FILE, LINK, SYMLINK, CHAR_DEVICE,
108      * BLOCK_DEVICE, or DIRECTORY.
109      *
110      * @param type
111      */

112     public void setFileType(int type) {
113         this.type = type;
114     }
115
116     /**
117      * Sets the mode of the file in UNIX permissions format.
118      *
119      * @param mode
120      */

121     public void setMode(long mode) {
122         this.mode = mode;
123     }
124
125     /**
126      * Sets the size of the file in bytes.
127      *
128      * @param size
129      */

130     public void setSize(long size) {
131         this.size = size;
132     }
133
134     /**
135      * Sets the modification time of the file in seconds since January
136      * 1st 1970.
137      *
138      * @param time
139      */

140     public void setTime(long time) {
141         this.time = time;
142     }
143 }
144
Popular Tags