001: /*******************************************************************************
002: * Copyright (c) 2004, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.internal.wizards.datatransfer;
011:
012: /**
013: * Representation of a file in a tar archive.
014: *
015: * @since 3.1
016: */
017: public class TarEntry implements Cloneable {
018: private String name;
019: private long mode, time, size;
020: private int type;
021: int filepos;
022:
023: /**
024: * Entry type for normal files.
025: */
026: public static final int FILE = '0';
027:
028: /**
029: * Entry type for directories.
030: */
031: public static final int DIRECTORY = '5';
032:
033: /**
034: * Create a new TarEntry for a file of the given name at the
035: * given position in the file.
036: *
037: * @param name filename
038: * @param pos position in the file in bytes
039: */
040: TarEntry(String name, int pos) {
041: this .name = name;
042: mode = 0644;
043: type = FILE;
044: filepos = pos;
045: time = System.currentTimeMillis() / 1000;
046: }
047:
048: /**
049: * Create a new TarEntry for a file of the given name.
050: *
051: * @param name filename
052: */
053: public TarEntry(String name) {
054: this (name, -1);
055: }
056:
057: /**
058: * Returns the type of this file, one of FILE, LINK, SYM_LINK,
059: * CHAR_DEVICE, BLOCK_DEVICE, DIRECTORY or FIFO.
060: *
061: * @return file type
062: */
063: public int getFileType() {
064: return type;
065: }
066:
067: /**
068: * Returns the mode of the file in UNIX permissions format.
069: *
070: * @return file mode
071: */
072: public long getMode() {
073: return mode;
074: }
075:
076: /**
077: * Returns the name of the file.
078: *
079: * @return filename
080: */
081: public String getName() {
082: return name;
083: }
084:
085: /**
086: * Returns the size of the file in bytes.
087: *
088: * @return filesize
089: */
090: public long getSize() {
091: return size;
092: }
093:
094: /**
095: * Returns the modification time of the file in seconds since January
096: * 1st 1970.
097: *
098: * @return time
099: */
100: public long getTime() {
101: return time;
102: }
103:
104: /**
105: * Sets the type of the file, one of FILE, LINK, SYMLINK, CHAR_DEVICE,
106: * BLOCK_DEVICE, or DIRECTORY.
107: *
108: * @param type
109: */
110: public void setFileType(int type) {
111: this .type = type;
112: }
113:
114: /**
115: * Sets the mode of the file in UNIX permissions format.
116: *
117: * @param mode
118: */
119: public void setMode(long mode) {
120: this .mode = mode;
121: }
122:
123: /**
124: * Sets the size of the file in bytes.
125: *
126: * @param size
127: */
128: public void setSize(long size) {
129: this .size = size;
130: }
131:
132: /**
133: * Sets the modification time of the file in seconds since January
134: * 1st 1970.
135: *
136: * @param time
137: */
138: public void setTime(long time) {
139: this.time = time;
140: }
141: }
|