1 /*******************************************************************************
2 * Copyright (c) 2015 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Marc-Andre Laperle - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.internal
.tmf
.ui
.project
.wizards
.importtrace
;
16 import java
.io
.IOException
;
19 import org
.eclipse
.core
.runtime
.IPath
;
20 import org
.eclipse
.core
.runtime
.Path
;
21 import org
.eclipse
.core
.runtime
.URIUtil
;
22 import org
.eclipse
.ui
.internal
.wizards
.datatransfer
.TarEntry
;
25 * The "Tar" implementation of an IFileSystemObject, entries can also be Gzipped
26 * and are uncompressed transparently.
28 @SuppressWarnings("restriction")
29 class TarFileSystemObject
implements IFileSystemObject
{
31 private TarEntry fFileSystemObject
;
32 private String fArchivePath
;
34 TarFileSystemObject(TarEntry fileSystemObject
, String archivePath
) {
35 fFileSystemObject
= fileSystemObject
;
36 fArchivePath
= archivePath
;
40 public String
getName() {
41 return new Path(fFileSystemObject
.getName()).lastSegment();
45 public String
getAbsolutePath() {
46 throw new UnsupportedOperationException();
50 public boolean exists() {
55 public String
getSourceLocation() {
56 File file
= new File(fArchivePath
);
58 file
= file
.getCanonicalFile();
59 } catch (IOException e
) {
60 // Will still work but might have extra ../ in the path
62 URI uri
= file
.toURI();
63 IPath entryPath
= new Path(fFileSystemObject
.getName());
65 URI jarURI
= entryPath
.isRoot() ? URIUtil
.toJarURI(uri
, Path
.EMPTY
) : URIUtil
.toJarURI(uri
, entryPath
);
66 return URIUtil
.toUnencodedString(jarURI
);
70 public Object
getRawFileSystemObject() {
71 return fFileSystemObject
;
75 public boolean isDirectory() {
76 return fFileSystemObject
.getFileType() == TarEntry
.DIRECTORY
;