Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 89809 Details for
Bug 195402
[api] RSE should support gzipped tar archives (*.tgz, *.tar.gz)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch for Bug 195402
patch_195402.txt (text/plain), 15.79 KB, created by
Johnson Ma
on 2008-02-14 23:35:52 EST
(
hide
)
Description:
Patch for Bug 195402
Filename:
MIME Type:
Creator:
Johnson Ma
Created:
2008-02-14 23:35:52 EST
Size:
15.79 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rse.services >Index: clientserver/org/eclipse/rse/services/clientserver/archiveutils/ArchiveHandlerManager.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/ArchiveHandlerManager.java,v >retrieving revision 1.10 >diff -u -r1.10 ArchiveHandlerManager.java >--- clientserver/org/eclipse/rse/services/clientserver/archiveutils/ArchiveHandlerManager.java 11 Feb 2008 16:38:31 -0000 1.10 >+++ clientserver/org/eclipse/rse/services/clientserver/archiveutils/ArchiveHandlerManager.java 15 Feb 2008 03:05:35 -0000 >@@ -25,6 +25,7 @@ > import java.lang.reflect.Constructor; > import java.lang.reflect.InvocationTargetException; > import java.util.HashMap; >+import java.util.Iterator; > > /** > * This class manages all the Archive Handlers that correspond to the archive file that the system >@@ -40,6 +41,7 @@ > public static final String VIRTUAL_SEPARATOR = "#virtual#/"; //$NON-NLS-1$ > public static final String VIRTUAL_CANONICAL_SEPARATOR = "#virtual#"; //$NON-NLS-1$ > public static final String VIRTUAL_FOLDER_SEPARATOR = "/"; //$NON-NLS-1$ >+ public static final String EXTENSION_SEPARATOR = "."; //$NON-NLS-1$ > > // the singleton instance > protected static ArchiveHandlerManager _instance = new ArchiveHandlerManager(); >@@ -116,7 +118,7 @@ > } > else > { >- if (_handlerTypes.containsKey(getExtension(file))) >+ if (getRegisteredExtension(file)!=null) > { > return true; > } >@@ -136,6 +138,10 @@ > */ > public boolean isRegisteredArchive(String filename) > { >+ return getRegisteredExtension(filename) == null?false:true; >+ //the code below doesn't support extension like fool.tar.gz, >+ //changed to compare file name against registered extensions >+ /* > if (_handlerTypes.containsKey(getExtension(filename))) > { > return true; >@@ -144,13 +150,49 @@ > { > return false; > } >+ */ > } >+ >+ /** >+ * check if the file extension is registered archive type. >+ * notice here, the getExtension method does't work for name like fool.tar.gz >+ * @param file the file to check >+ * @return extension or null >+ */ >+ protected String getRegisteredExtension(File file) >+ { >+ String fileName = file.getName(); >+ return getRegisteredExtension(fileName); >+ >+ } >+ /** >+ * check if the file extension is registered archive type. >+ * notice here, the getExtension method does't work for name like fool.tar.gz >+ * @param fileName the file name to check >+ * @return extension or null >+ */ >+ protected String getRegisteredExtension(String fileName) >+ { >+ Iterator itor = _handlerTypes.keySet().iterator(); >+ while(itor.hasNext()) >+ { >+ String ext = ((String)itor.next()).toLowerCase(); >+ if (fileName.endsWith(EXTENSION_SEPARATOR + ext)) >+ { >+ return ext; >+ } >+ >+ } >+ return null; >+ } >+ > /** > * @param file the file whose extension we are computing. > * @return the extension of <code>file</code>. "Extension" is > * defined as any letters in the filename after the last ".". > * Returns "" if there is no extension. > */ >+ /* > protected String getExtension(File file) > { > String filename = file.getName(); >@@ -158,6 +200,8 @@ > if (i == -1) return ""; //$NON-NLS-1$ > return filename.substring(i+1).toLowerCase(); > } >+ */ >+ > > /** > * @param filename the name of the file whose extension we are computing. >@@ -165,12 +209,14 @@ > * defined as any letters in the filename after the last ".". > * Returns "" if there is no extension. > */ >+ /* > protected String getExtension(String filename) > { > int i = filename.lastIndexOf("."); //$NON-NLS-1$ > if (i == -1) return ""; //$NON-NLS-1$ > return filename.substring(i+1).toLowerCase(); > } >+ */ > > /** > * Given the absolute path to a virtual object, returns that object >@@ -212,8 +258,8 @@ > } > else { > // find registered handler based on file's extension >- String ext = getExtension(file); >- if (!_handlerTypes.containsKey(ext)) >+ String ext = getRegisteredExtension(file); >+ if (ext == null) > { > //System.out.println("Unknown archive file type: " + ext); > return null; >Index: clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTarHandler.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTarHandler.java,v >retrieving revision 1.12 >diff -u -r1.12 SystemTarHandler.java >--- clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTarHandler.java 23 Jan 2008 03:57:16 -0000 1.12 >+++ clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTarHandler.java 15 Feb 2008 03:05:36 -0000 >@@ -30,6 +30,7 @@ > import java.io.BufferedReader; > import java.io.File; > import java.io.FileInputStream; >+import java.io.FileNotFoundException; > import java.io.FileOutputStream; > import java.io.FilePermission; > import java.io.IOException; >@@ -1230,7 +1231,7 @@ > > // open a new temp file which will be our destination for the new tar file > outputTempFile = new File(file.getAbsolutePath() + "temp"); //$NON-NLS-1$ >- outStream = new TarOutputStream(new FileOutputStream(outputTempFile)); >+ outStream = getTarOutputStream(outputTempFile); > > // get all the entries in the current tar > VirtualChild[] children = getVirtualChildrenList(archiveOperationMonitor); >@@ -1670,7 +1671,7 @@ > // open a new temp file which will be our destination for the new tar file > File outputTempFile = new File(getArchive().getAbsolutePath() + "temp"); //$NON-NLS-1$ > >- TarOutputStream outStream = new TarOutputStream(new FileOutputStream(outputTempFile)); >+ TarOutputStream outStream = getTarOutputStream(outputTempFile); > > // get all the entries > VirtualChild[] children = getVirtualChildrenList(archiveOperationMonitor); >@@ -1779,7 +1780,7 @@ > > // open a new temp file which will be our destination for the new tar file > outputTempFile = new File(file.getAbsolutePath() + "temp"); //$NON-NLS-1$ >- TarOutputStream outStream = new TarOutputStream(new FileOutputStream(outputTempFile)); >+ TarOutputStream outStream = getTarOutputStream(outputTempFile); > > // get all the entries in the current tar > VirtualChild[] children = getVirtualChildrenList(archiveOperationMonitor); >@@ -1905,7 +1906,7 @@ > > // open a new temp file which will be our destination for the new tar file > outputTempFile = new File(file.getAbsolutePath() + "temp"); //$NON-NLS-1$ >- TarOutputStream outStream = new TarOutputStream(new FileOutputStream(outputTempFile)); >+ TarOutputStream outStream = getTarOutputStream(outputTempFile); > > // get all the entries > VirtualChild[] children = getVirtualChildrenList(archiveOperationMonitor); >@@ -2192,7 +2193,7 @@ > > // open a new temp file which will be our destination for the new tar file > outputTempFile = new File(file.getAbsolutePath() + "temp"); //$NON-NLS-1$ >- outStream = new TarOutputStream(new FileOutputStream(outputTempFile)); >+ outStream = getTarOutputStream(outputTempFile); > > // get all the entries > VirtualChild[] children = getVirtualChildrenList(archiveOperationMonitor); >@@ -2343,7 +2344,7 @@ > try { > > // create output stream >- TarOutputStream outStream = new TarOutputStream(new FileOutputStream(file)); >+ TarOutputStream outStream = getTarOutputStream(file); > > // close output stream, so we have an empty tar file > outStream.close(); >@@ -2601,4 +2602,16 @@ > archiveOperationMonitor.setDone(true); > } > } >+ >+ /** >+ * get the tar output stream from file, >+ * this method can be override by subclass to return compressed output steam if needed >+ * @param outputFile the output file to create stream >+ * @return OutputStream the output stream to write >+ * @throws FileNotFoundException when the output file doesn't exists >+ */ >+ protected TarOutputStream getTarOutputStream(File outputFile) throws FileNotFoundException { >+ TarOutputStream outStream = new TarOutputStream(new FileOutputStream(outputFile)); >+ return outStream; >+ } > } >Index: clientserver/org/eclipse/rse/internal/services/clientserver/archiveutils/TarFile.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/internal/services/clientserver/archiveutils/TarFile.java,v >retrieving revision 1.3 >diff -u -r1.3 TarFile.java >--- clientserver/org/eclipse/rse/internal/services/clientserver/archiveutils/TarFile.java 5 Jun 2007 10:37:07 -0000 1.3 >+++ clientserver/org/eclipse/rse/internal/services/clientserver/archiveutils/TarFile.java 15 Feb 2008 03:05:34 -0000 >@@ -195,7 +195,7 @@ > * @return the input stream for the tar file. > * @throws FileNotFoundException if the file does not exist. > */ >- private InputStream getInputStream() throws FileNotFoundException { >+ protected InputStream getInputStream() throws FileNotFoundException { > FileInputStream stream = new FileInputStream(file); > return stream; > } >Index: clientserver/org/eclipse/rse/internal/services/clientserver/archiveutils/TgzFile.java >=================================================================== >RCS file: clientserver/org/eclipse/rse/internal/services/clientserver/archiveutils/TgzFile.java >diff -N clientserver/org/eclipse/rse/internal/services/clientserver/archiveutils/TgzFile.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ clientserver/org/eclipse/rse/internal/services/clientserver/archiveutils/TgzFile.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,60 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Eclipse.org. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ */ >+package org.eclipse.rse.internal.services.clientserver.archiveutils; >+ >+import java.io.File; >+import java.io.FileNotFoundException; >+import java.io.IOException; >+import java.io.InputStream; >+import java.util.zip.GZIPInputStream; >+ >+/** >+ * This class is used to read entries from tar.gz file >+ * It read compressed data from GZIPInputStream >+ * @author jma >+ */ >+public class TgzFile extends TarFile { >+ >+ /** >+ * Opens a tar.gz file for reading given the specified File object. >+ * @param file the tar.gz file to be opened for reading. >+ * @throws FileNotFoundException if the file does not exist. >+ * @throws IOException if an I/O error occurs. >+ */ >+ public TgzFile(File file) throws FileNotFoundException, IOException { >+ super(file); >+ } >+ >+ /** >+ * Opens a tar.gz file for reading given the file name. >+ * @param name the name of the tar file to be opened for reading. >+ * @throws FileNotFoundException if the file with the given name does not exist. >+ * @throws IOException if an I/O error occurs. >+ */ >+ public TgzFile(String name) throws FileNotFoundException, IOException { >+ super(name); >+ } >+ >+ /** >+ * Gets the input stream for the tar.gz file. >+ * Get file input steam from superclass, wrap it using GZipInputSteam >+ * @return the input stream for the tar file. >+ * @throws FileNotFoundException if the file does not exist. >+ */ >+ protected InputStream getInputStream() throws FileNotFoundException { >+ InputStream fileInputStream = super.getInputStream(); >+ GZIPInputStream zipInputStream = null; >+ try{ >+ zipInputStream = new GZIPInputStream(fileInputStream); >+ } catch (IOException ioe) { >+ throw new FileNotFoundException(ioe.getMessage()); >+ } >+ return zipInputStream; >+ } >+ >+} >Index: clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTgzHandler.java >=================================================================== >RCS file: clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTgzHandler.java >diff -N clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTgzHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTgzHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,48 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Eclipse.org. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ */ >+package org.eclipse.rse.services.clientserver.archiveutils; >+ >+import java.io.File; >+import java.io.IOException; >+ >+import org.eclipse.rse.internal.services.clientserver.archiveutils.TarFile; >+import org.eclipse.rse.internal.services.clientserver.archiveutils.TgzFile; >+ >+/** >+ * handler class for .tar.gz and .tgz files >+ * @author jma >+ * >+ */ >+public class SystemTgzHandler extends SystemTarHandler { >+ >+ /** >+ * constructor for the tgz handler >+ * @param file the .tar.gz or .tgz file >+ */ >+ public SystemTgzHandler(File file) throws IOException { >+ super(file); >+ } >+ >+ /** >+ * Gets a tar.gz file from the underlying file. >+ * @return the tar file, or <code>null</code> if the tar file does not exist. >+ */ >+ protected TarFile getTarFile() { >+ >+ TarFile tarFile = null; >+ >+ try { >+ tarFile = new TgzFile(file); >+ } >+ catch (IOException e) { >+ // TODO: log error >+ } >+ >+ return tarFile; >+ } >+} >#P org.eclipse.rse.files.ui >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.files.ui/plugin.xml,v >retrieving revision 1.22 >diff -u -r1.22 plugin.xml >--- plugin.xml 16 Jan 2008 18:28:19 -0000 1.22 >+++ plugin.xml 15 Feb 2008 03:05:40 -0000 >@@ -309,6 +309,18 @@ > id="org.eclipse.rse.services.clientserver.archiveutils.systemjarhandler"> > </archivehandler> > <archivehandler >+ fileNameExtension="tar.gz" >+ name="SystemTargzHandler" >+ class="org.eclipse.rse.services.clientserver.archiveutils.SystemTgzHandler" >+ id="org.eclipse.rse.services.clientserver.archiveutils.systemtargzhandler"> >+ </archivehandler> >+ <archivehandler >+ fileNameExtension="tgz" >+ name="SystemTgzHandler" >+ class="org.eclipse.rse.services.clientserver.archiveutils.SystemTgzHandler" >+ id="org.eclipse.rse.services.clientserver.archiveutils.systemtgzhandler"> >+ </archivehandler> >+ <archivehandler > fileNameExtension="tar" > name="SystemTarHandler" > class="org.eclipse.rse.services.clientserver.archiveutils.SystemTarHandler" >#P org.eclipse.rse.services.dstore >Index: miners/org/eclipse/rse/dstore/universal/miners/UniversalFileSystemMiner.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/dstore/universal/miners/UniversalFileSystemMiner.java,v >retrieving revision 1.34 >diff -u -r1.34 UniversalFileSystemMiner.java >--- miners/org/eclipse/rse/dstore/universal/miners/UniversalFileSystemMiner.java 12 Feb 2008 23:42:11 -0000 1.34 >+++ miners/org/eclipse/rse/dstore/universal/miners/UniversalFileSystemMiner.java 15 Feb 2008 03:05:43 -0000 >@@ -98,6 +98,8 @@ > _archiveHandlerManager = ArchiveHandlerManager.getInstance(); > _archiveHandlerManager.setRegisteredHandler("zip", SystemZipHandler.class); //$NON-NLS-1$ > _archiveHandlerManager.setRegisteredHandler("jar", SystemJarHandler.class); //$NON-NLS-1$ >+ _archiveHandlerManager.setRegisteredHandler("tar.gz", SystemJarHandler.class); //$NON-NLS-1$ >+ _archiveHandlerManager.setRegisteredHandler("tgz", SystemJarHandler.class); //$NON-NLS-1$ > _archiveHandlerManager.setRegisteredHandler("tar", SystemTarHandler.class); //$NON-NLS-1$ > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 195402
:
89809
|
91652
|
92312