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
.apache
.commons
.compress
.archivers
.tar
.TarArchiveEntry
;
20 import org
.eclipse
.core
.runtime
.IPath
;
21 import org
.eclipse
.core
.runtime
.Path
;
22 import org
.eclipse
.core
.runtime
.URIUtil
;
25 * The "Tar" implementation of an IFileSystemObject, entries can also be Gzipped
26 * and are uncompressed transparently.
28 class TarFileSystemObject
implements IFileSystemObject
{
30 private TarArchiveEntry fFileSystemObject
;
31 private String fArchivePath
;
33 TarFileSystemObject(TarArchiveEntry fileSystemObject
, String archivePath
) {
34 fFileSystemObject
= fileSystemObject
;
35 fArchivePath
= archivePath
;
39 public String
getName() {
40 return new Path(fFileSystemObject
.getName()).lastSegment();
44 public String
getAbsolutePath() {
45 throw new UnsupportedOperationException();
49 public boolean exists() {
54 public String
getSourceLocation() {
55 File file
= new File(fArchivePath
);
57 file
= file
.getCanonicalFile();
58 } catch (IOException e
) {
59 // Will still work but might have extra ../ in the path
61 URI uri
= file
.toURI();
62 IPath entryPath
= new Path(fFileSystemObject
.getName());
64 URI jarURI
= entryPath
.isRoot() ? URIUtil
.toJarURI(uri
, Path
.EMPTY
) : URIUtil
.toJarURI(uri
, entryPath
);
65 return URIUtil
.toUnencodedString(jarURI
);
69 public Object
getRawFileSystemObject() {
70 return fFileSystemObject
;
74 public boolean isDirectory() {
75 return fFileSystemObject
.isDirectory();