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
;
24 * The "GZIP" implementation of an IFileSystemObject. For a GZIP file that is
27 class GzipFileSystemObject
implements IFileSystemObject
{
29 private GzipEntry fFileSystemObject
;
30 private String fArchivePath
;
32 GzipFileSystemObject(GzipEntry fileSystemObject
, String archivePath
) {
33 fFileSystemObject
= fileSystemObject
;
34 fArchivePath
= archivePath
;
38 public String
getName() {
39 return new Path(fFileSystemObject
.getName()).lastSegment();
43 public String
getAbsolutePath() {
44 throw new UnsupportedOperationException();
48 public boolean exists() {
53 public String
getSourceLocation() {
54 File file
= new File(fArchivePath
);
56 file
= file
.getCanonicalFile();
57 } catch (IOException e
) {
58 // Will still work but might have extra ../ in the path
60 URI uri
= file
.toURI();
61 IPath entryPath
= new Path(fFileSystemObject
.getName());
63 URI jarURI
= entryPath
.isRoot() ? URIUtil
.toJarURI(uri
, Path
.EMPTY
) : URIUtil
.toJarURI(uri
, entryPath
);
64 return URIUtil
.toUnencodedString(jarURI
);
68 public Object
getRawFileSystemObject() {
69 return fFileSystemObject
;