1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-15 04:55:22 +02:00

[cleanup] add API "since" tags

This commit is contained in:
Martin Oberhuber 2008-03-28 13:08:44 +00:00
parent 946da798f3
commit 7ba4eede2a
10 changed files with 1855 additions and 1490 deletions

View file

@ -20,9 +20,15 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
</natures>
</projectDescription>

View file

@ -37,10 +37,25 @@ import java.util.Iterator;
*/
public class ArchiveHandlerManager
{
// The string that separates the virtual part of an absolute path from the real part
/**
* The string that separates the virtual part of an absolute path from the
* real part.
*/
public static final String VIRTUAL_SEPARATOR = "#virtual#/"; //$NON-NLS-1$
public static final String VIRTUAL_CANONICAL_SEPARATOR = "#virtual#"; //$NON-NLS-1$
/**
* Folder separator used in virtual paths inside the archive, i.e. after the
* VIRTUAL_SEPARATOR.
*
* @since org.eclipse.rse.services 3.0
*/
public static final String VIRTUAL_FOLDER_SEPARATOR = "/"; //$NON-NLS-1$
/**
* Character used to separate file extension from file name. This is used in
* order to recognize file patterns that should be treated as archives.
*
* @since org.eclipse.rse.services 3.0
*/
public static final String EXTENSION_SEPARATOR = "."; //$NON-NLS-1$
// the singleton instance
@ -142,11 +157,11 @@ public class ArchiveHandlerManager
}
/**
* check if the file extension is registered archive type.
* 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 registered extension or null
* @since 3.0
* @since org.eclipse.rse.services 3.0
*/
protected String getRegisteredExtension(File file)
{
@ -158,7 +173,7 @@ public class ArchiveHandlerManager
* check if the file extension is registered archive type.
* @param fileName the file name to check
* @return registered extension or null
* @since 3.0
* @since org.eclipse.rse.services 3.0
*/
protected String getRegisteredExtension(String fileName)
{
@ -242,7 +257,7 @@ public class ArchiveHandlerManager
if (handler != null && handler.exists())
{
return handler;
return handler;
}
else {
// find registered handler based on file's extension

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2003, 2007 IBM Corporation and others.
* Copyright (c) 2003, 2008 IBM Corporation and others.
* 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
@ -12,8 +12,8 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* {Name} (company) - description of contribution.
* Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
* Xuan Chen (IBM) - [160775][api][breaking] rename (at least within a zip) blocks UI thread
* Martin Oberhuber (Wind River) - [cleanup] add API "since" tags to Archive Handler Javadoc
*******************************************************************************/
package org.eclipse.rse.services.clientserver.archiveutils;
@ -28,205 +28,279 @@ import org.eclipse.rse.services.clientserver.search.SystemSearchStringMatcher;
/**
* An interface that allows implementing classes to create their own handlers
* for various types of archive files, ie: zip, jar, tar, rpm.
*
* @author mjberger
* An interface that allows implementing classes to create their own
* Handlers for various types of Archive files, ie: zip, jar, tar, rpm
*/
public interface ISystemArchiveHandler
{
/**
* Turns the archive that this handler represents into a new, empty archive.
* (The archive could not exist before, in which case this would be a true
* creation).
* @return Whether or not the blank archive was successfuly created.
*
* @return Whether or not the blank archive was successfully created.
*/
public boolean create();
/**
* @return an array containing all the entries in the archive file
* in a flat format, where the entries' filenames are prepended by
* the path to the entry within the virtual file system. If there
* are no entries in the file, returns an array of size 0.
* Return a flat list of entries in an archive.
*
* @param archiveOperationMonitor the operation progress monitor
* @return an array containing all the entries in the archive file in a flat
* format, where the entries' filenames are prepended by the path to
* the entry within the virtual file system. If there are no entries
* in the file, returns an array of size 0.
*
* @since org.eclipse.rse.services 3.0
*/
public VirtualChild[] getVirtualChildrenList(ISystemOperationMonitor archiveOperationMonitor);
/**
* @return an array containing all the entries in the archive file
* in a flat format, whose full paths begin with the String <code>parent</code>.
* Returns an array of length 0 if there are no such entries.
* Return a flat list of entries in an archive, whose full paths begin with
* the given parent prefix.
*
* @param parent full path of the parent
* @param archiveOperationMonitor the operation progress monitor
* @return an array containing all the entries in the archive file in a flat
* format, whose full paths begin with the String
* <code>parent</code>. Returns an array of length 0 if there are
* no such entries.
*
* @since org.eclipse.rse.services 3.0
*/
public VirtualChild[] getVirtualChildrenList(String parent, ISystemOperationMonitor archiveOperationMonitor);
/**
* @return an array containing the virtual children of the virtual
* directory named <code>fullVirtualName</code>. If <code>fullVirtualName</code> is "",
* returns the top level in the virtual file system tree. If there are no
* values to return, returns null.
* Return the children of a specified node in an archive.
*
* @param fullVirtualName full virtual path of the parent
* @param archiveOperationMonitor the operation progress monitor
* @return an array containing the virtual children of the virtual directory
* named <code>fullVirtualName</code>. If
* <code>fullVirtualName</code> is "", returns the top level in
* the virtual file system tree. If there are no values to return,
* returns null.
*
* @since org.eclipse.rse.services 3.0
*/
public VirtualChild[] getVirtualChildren(String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor);
/**
* @return an array containing the virtual children of the virtual
* directory named <code>fullVirtualName</code> that are themselves directories.
* If <code>fullVirtualName</code> is "",
* returns the top level of directories in the virtual file system tree.
* If there are no values to return, returns null.
* Return those children of a specified node in an archive, which are
* folders.
*
* @param fullVirtualName full virtual path of the parent
* @param archiveOperationMonitor the operation progress monitor
* @return an array containing the virtual children of the virtual directory
* named <code>fullVirtualName</code> that are themselves
* directories. If <code>fullVirtualName</code> is "", returns the
* top level of directories in the virtual file system tree. If
* there are no values to return, returns null.
*
* @since org.eclipse.rse.services 3.0
*/
public VirtualChild[] getVirtualChildFolders(String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor);
/**
* @return the virtual File or Folder referred to by <code>fullVirtualName</code>.
* This method never returns null. In cases where the VirtualChild does not
* physically exist in the archive, this method returns a new VirtualChild object
* whose exists() method returns false.
* Return an archive node specified by a given virtual path.
*
* @param fullVirtualName full virtual path of the object to retrieve
* @param archiveOperationMonitor the operation progress monitor
* @return the virtual File or Folder referred to by
* <code>fullVirtualName</code>. This method never returns null.
* In cases where the VirtualChild does not physically exist in the
* archive, this method returns a new VirtualChild object whose
* exists() method returns false.
*
* @since org.eclipse.rse.services 3.0
*/
public VirtualChild getVirtualFile(String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor);
/**
* @return Whether or not the virtual file or folder named <code>fullVirtualName</code>
* exists in the archive (physically).
* Check whether a given virtual node exists in an archive.
*
* @param fullVirtualName full virtual path of the object
* @param archiveOperationMonitor the operation progress monitor
* @return Whether or not the virtual file or folder named
* <code>fullVirtualName</code> exists in the archive
* (physically).
*
* @since org.eclipse.rse.services 3.0
*/
public boolean exists(String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor);
/**
* Check if the archive handler implementation associated with this class
* exists.
*
* @return Whether or not the handler exists. Usually false if the archive
* is corrupted or unreadable.
* is corrupted or unreadable.
*/
public boolean exists();
/**
* Return the archive that this handler deals with.
*
* @return the archive that this handler deals with
*/
public File getArchive();
/**
* @return the current timestamp (last modified) for the entry in the archive named
* <code>fullVirtualName</code>
/**
* Return the timestamp for an archive node.
*
* @param fullVirtualName virtual path specifying the node to check
* @return the current timestamp (last modified) for the archive entry named
* <code>fullVirtualName</code>
*/
public long getTimeStampFor(String fullVirtualName);
/**
* @return the current size (uncompressed) for the entry in the archive named
* <code>fullVirtualName</code>
* Return the size for an archive node.
*
* @param fullVirtualName virtual path specifying the node to check
* @return the current size (uncompressed) for the entry in the archive
* named <code>fullVirtualName</code>
*/
public long getSizeFor(String fullVirtualName);
/**
* Extracts the virtual file named <code>fullVirtualName</code> from the archive,
* placing the results in <code>destination</code>.
* @param fullVirtualName The full path and name of the virtual file in the archive.
* Extracts the virtual file named <code>fullVirtualName</code> from the
* archive, placing the results in <code>destination</code>.
*
* @param fullVirtualName The full path and name of the virtual file in the
* archive.
* @param destination The destination file for the extracted virtual file.
* @param archiveOperationMonitor the operation progress monitor
* @return true iff the extraction is successful
* @return <code>true</code> if the extraction is successful,
* <code>false</code> otherwise
* @since org.eclipse.rse.services 3.0
*/
public boolean extractVirtualFile(String fullVirtualName, File destination, ISystemOperationMonitor archiveOperationMonitor);
/**
* Extracts the virtual file named <code>fullVirtualName</code> from the archive,
* placing the results in <code>destination</code>. Extracts to the native encoding, but assumes
* that the source was archived using <code>sourceEncoding</code> if <code>isText</code> is true.
* @param fullVirtualName The full path and name of the virtual file in the archive.
* Extracts the virtual file named <code>fullVirtualName</code> from the
* archive, placing the results in <code>destination</code>. Extracts to
* the native encoding, but assumes that the source was archived using
* <code>sourceEncoding</code> if <code>isText</code> is true.
*
* @param fullVirtualName The full path and name of the virtual file in the
* archive.
* @param destination The destination file for the extracted virtual file.
* @param sourceEncoding The encoding of the file in the archive.
* @param isText Whether or not the virtual file is a text file.
* @param archiveOperationMonitor the operation progress monitor
* @return true iff the extraction is successful
* @return <code>true</code> if the extraction is successful,
* <code>false</code> otherwise
* @since org.eclipse.rse.services 3.0
*/
public boolean extractVirtualFile(String fullVirtualName, File destination, String sourceEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor);
/**
* Extracts the directory <code>dir</code> (and its children) from
* the archive and places the results in the directory <code>destinationParent</code>.
* Extracts the directory <code>dir</code> (and its children) from the
* archive and places the results in the directory
* <code>destinationParent</code>.
*
* @param dir The full name of the virtual directory to extract
* @param destinationParent A handle to the directory in which the extracted
* directory will be placed as a subdirectory.
* directory will be placed as a subdirectory.
* @param archiveOperationMonitor the operation progress monitor
* @return true iff the extraction is successful
* @return <code>true</code> if the extraction is successful,
* <code>false</code> otherwise
* @since org.eclipse.rse.services 3.0
*/
public boolean extractVirtualDirectory(String dir, File destinationParent, ISystemOperationMonitor archiveOperationMonitor);
/**
* Extracts the directory <code>dir</code> (and its children) from
* the archive and places the results in the directory <code>destinationParent</code>.
* Extracts to the native encoding (if <code>isText</code>), but assumes
* that the source was archived using <code>sourceEncoding</code>.
* Extracts the directory <code>dir</code> (and its children) from the
* archive and places the results in the directory
* <code>destinationParent</code>. Extracts to the native encoding (if
* <code>isText</code>), but assumes that the source was archived using
* <code>sourceEncoding</code>.
*
* @param dir The full name of the virtual directory to extract
* @param destinationParent A handle to the directory in which the extracted
* directory will be placed as a subdirectory.
* directory will be placed as a subdirectory.
* @param sourceEncoding The encoding of the files in the archive.
* @param isText Whether or not the files in the directory are text files
* @param archiveOperationMonitor the operation progress monitor
* @return true iff the extraction is successful
* @return <code>true</code> if the extraction is successful,
* <code>false</code> otherwise
* @since org.eclipse.rse.services 3.0
*/
public boolean extractVirtualDirectory(String dir, File destinationParent, String sourceEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor);
/**
* Extracts the directory <code>dir</code> (and its children) from
* the archive and places the results in the directory <code>destinationParent</code>.
* The results will be named destination.getName() rather than <code>dir</code>'s name.
* Extracts the directory <code>dir</code> (and its children) from the
* archive and places the results in the directory
* <code>destinationParent</code>. The results will be named
* destination.getName() rather than <code>dir</code>'s name.
*
* @param dir The full name of the virtual directory to extract
* @param destinationParent A handle to the directory in which the extracted
* directory will be placed as a subdirectory.
* @param destination A handle to the directory that will be created. Whatever
* contents are in that directory will be replaced with what is extracted from
* the archive.
* directory will be placed as a subdirectory.
* @param destination A handle to the directory that will be created.
* Whatever contents are in that directory will be replaced with
* what is extracted from the archive.
* @param archiveOperationMonitor the operation progress monitor
* @return true iff the extraction is successful
* @return <code>true</code> if the extraction is successful,
* <code>false</code> otherwise
* @since org.eclipse.rse.services 3.0
*/
public boolean extractVirtualDirectory(String dir, File destinationParent, File destination, ISystemOperationMonitor archiveOperationMonitor);
/**
* Extracts the directory <code>dir</code> (and its children) from
* the archive and places the results in the directory <code>destinationParent</code>.
* The results will be named destination.getName() rather than <code>dir</code>'s name.
* Extracts to the native encoding (if <code>isText</code>), but assumes
* that the source was archived using <code>sourceEncoding</code>.
* Extracts the directory <code>dir</code> (and its children) from the
* archive and places the results in the directory
* <code>destinationParent</code>. The results will be named
* destination.getName() rather than <code>dir</code>'s name. Extracts to
* the native encoding (if <code>isText</code>), but assumes that the
* source was archived using <code>sourceEncoding</code>.
*
* @param dir The full name of the virtual directory to extract
* @param destinationParent A handle to the directory in which the extracted
* directory will be placed as a subdirectory.
* @param destination A handle to the directory that will be created. Whatever
* contents are in that directory will be replaced with what is extracted from
* the archive.
* directory will be placed as a subdirectory.
* @param destination A handle to the directory that will be created.
* Whatever contents are in that directory will be replaced with
* what is extracted from the archive.
* @param sourceEncoding The encoding of the files in the archive.
* @param isText Whether or not the files to be extracted in the directory are all text files
* @param isText Whether or not the files to be extracted in the directory
* are all text files
* @param archiveOperationMonitor the operation progress monitor
* @return true iff the extraction is successful
* @return <code>true</code> if the extraction is successful,
* <code>false</code> otherwise
* @since org.eclipse.rse.services 3.0
*/
public boolean extractVirtualDirectory(String dir, File destinationParent, File destination, String sourceEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor);
/**
* Compresses the file <code>file</code> and adds it to the archive,
* placing it in the virtual directory <code>virtualPath</code>. Pass the
* name as the parameter <code>name</code>. If the virtual path does not exist
* in the archive, create it. If <code>file</code> is a directory, copy it and
* its contents into the archive, maintaining the tree structure.
* name as the parameter <code>name</code>. If the virtual path does not
* exist in the archive, create it. If <code>file</code> is a directory,
* copy it and its contents into the archive, maintaining the tree
* structure.
*
* @param file the file to be added to the archive
* @param virtualPath the destination of the file
* @param name the name of the result virtual file
* @param archiveOperationMonitor the operation progress monitor
* @return true if and only if the add was successful
* @return <code>true</code> if the addition is successful,
* <code>false</code> otherwise
* @since org.eclipse.rse.services 3.0
*/
public boolean add(File file, String virtualPath, String name, ISystemOperationMonitor archiveOperationMonitor);
/**
* Compresses the file <code>file</code> and adds it to the archive,
* saving it in the encoding specified by <code>encoding</code> if the isText is true.
* placing it in the virtual directory <code>virtualPath</code>. Pass the
* name as the parameter <code>name</code>. If the virtual path does not exist
* in the archive, create it. If <code>file</code> is a directory, copy it and
* its contents into the archive, maintaining the tree structure.
* saving it in the encoding specified by <code>encoding</code> if the
* isText is true. placing it in the virtual directory
* <code>virtualPath</code>. Pass the name as the parameter
* <code>name</code>. If the virtual path does not exist in the archive,
* create it. If <code>file</code> is a directory, copy it and its
* contents into the archive, maintaining the tree structure.
*
* @param file the file to be added to the archive
* @param virtualPath the destination of the file
* @param name the name of the result virtual file
@ -234,16 +308,20 @@ public interface ISystemArchiveHandler
* @param targetEncoding the encoding of the result file
* @param isText is the file a text file
* @param archiveOperationMonitor the operation progress monitor
* @return true if and only if the add was successful
* @return <code>true</code> if the addition is successful,
* <code>false</code> otherwise
* @since org.eclipse.rse.services 3.0
*/
public boolean add(File file, String virtualPath, String name, String sourceEncoding, String targetEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor);
/**
* Compresses the bytes in the InputStream <code>stream</code> and adds them as an entry to the archive,
* saving them in the encoding specified by <code>encoding</code> if <code>isText</code> is true, and
* placing it in the virtual directory <code>virtualPath</code>. Pass the
* name as the parameter <code>name</code>. If the virtual path does not exist
* in the archive, create it.
* Compresses the bytes in the InputStream <code>stream</code> and adds
* them as an entry to the archive, saving them in the encoding specified by
* <code>encoding</code> if <code>isText</code> is true, and placing it
* in the virtual directory <code>virtualPath</code>. Pass the name as
* the parameter <code>name</code>. If the virtual path does not exist in
* the archive, create it.
*
* @param stream the InputStream to be added as an entry to the archive
* @param virtualPath the destination of the stream
* @param name the name of the result virtual file
@ -251,17 +329,21 @@ public interface ISystemArchiveHandler
* @param targetEncoding the encoding of the result file
* @param isText is the file a text file
* @param archiveOperationMonitor the operation progress monitor
* @return true if and only if the add was successful
* @return <code>true</code> if the addition is successful,
* <code>false</code> otherwise
* @since org.eclipse.rse.services 3.0
*/
public boolean add(InputStream stream, String virtualPath, String name, String sourceEncoding, String targetEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor);
/**
* Compresses the file <code>file</code> and adds it to the archive,
* saving it in the encoding specified by <code>encoding</code> if the isText is true.
* placing it in the virtual directory <code>virtualPath</code>. Pass the
* name as the parameter <code>name</code>. If the virtual path does not exist
* in the archive, create it. If <code>file</code> is a directory, copy it and
* its contents into the archive, maintaining the tree structure.
* saving it in the encoding specified by <code>encoding</code> if the
* isText is true. placing it in the virtual directory
* <code>virtualPath</code>. Pass the name as the parameter
* <code>name</code>. If the virtual path does not exist in the archive,
* create it. If <code>file</code> is a directory, copy it and its
* contents into the archive, maintaining the tree structure.
*
* @param file the file to be added to the archive
* @param virtualPath the destination of the file
* @param name the name of the result virtual file
@ -269,31 +351,40 @@ public interface ISystemArchiveHandler
* @param targetEncoding the encoding of the result file
* @param typeRegistery file transfer mode (binary or text) of this file
* @param archiveOperationMonitor the operation progress monitor
* @return true if and only if the add was successful
* @return <code>true</code> if the addition is successful,
* <code>false</code> otherwise
* @since org.eclipse.rse.services 3.0
*/
public boolean add(File file, String virtualPath, String name, String sourceEncoding, String targetEncoding, ISystemFileTypes typeRegistery, ISystemOperationMonitor archiveOperationMonitor);
/**
* A generalization of the add method.
* Compresses the array of files <code>files</code> and adds each of them to the archive, placing them
* in the virtual directory <code>virtualPath</code>. Pass the names of the files
* as the parameter <code>names</code>, where <code>files[i]</code> has the name <code>names[i]</code>.
* If the virtual path does not exist in the archive, create it.
* A generalization of the add method. Compresses the array of files
* <code>files</code> and adds each of them to the archive, placing them
* in the virtual directory <code>virtualPath</code>. Pass the names of
* the files as the parameter <code>names</code>, where
* <code>files[i]</code> has the name <code>names[i]</code>. If the
* virtual path does not exist in the archive, create it.
*
* @param files the list of files to be added to the archive
* @param virtualPath the destination of the file
* @param names the names of the result virtual files
* @param archiveOperationMonitor the operation progress monitor
* @return true if and only if the add was successful
* @return <code>true</code> if the addition is successful,
* <code>false</code> otherwise
* @since org.eclipse.rse.services 3.0
*/
public boolean add(File[] files, String virtualPath, String[] names, ISystemOperationMonitor archiveOperationMonitor);
/**
* A generalization of the add method.
* Compresses the array of files <code>files</code> and adds each of them to the archive, placing them
* in the virtual directory <code>virtualPath</code>. Save the i'th file in the i'th encoding (if isText[i] is true)
* specified by <code>encodings</code>. Pass the names of the files
* as the parameter <code>names</code>, where <code>files[i]</code> has the name <code>names[i]</code>.
* If the virtual path does not exist in the archive, create it.
* A generalization of the add method. Compresses the array of files
* <code>files</code> and adds each of them to the archive, placing them
* in the virtual directory <code>virtualPath</code>. Save the i'th file
* in the i'th encoding (if isText[i] is true) specified by
* <code>encodings</code>. Pass the names of the files as the parameter
* <code>names</code>, where <code>files[i]</code> has the name
* <code>names[i]</code>. If the virtual path does not exist in the
* archive, create it.
*
* @param files the list of files to be added to the archive
* @param virtualPath the destination of the files
* @param names the names of the result virtual files
@ -301,7 +392,9 @@ public interface ISystemArchiveHandler
* @param targetEncodings the encoding of the result files
* @param isText file transfer mode (binary or text) of the files
* @param archiveOperationMonitor the operation progress monitor
* @return true if and only if the add was successful
* @return <code>true</code> if the addition is successful,
* <code>false</code> otherwise
* @since org.eclipse.rse.services 3.0
*/
public boolean add(File[] files, String virtualPath, String[] names, String[] sourceEncodings, String[] targetEncodings, boolean[] isText, ISystemOperationMonitor archiveOperationMonitor);
@ -309,20 +402,24 @@ public interface ISystemArchiveHandler
* Compress the file <code>file</code> and replace the virtual file
* referred to by <code>fullVirtualName</code> with the compressed file.
* Pass the name of the file as the parameter <code>name</code>.
*
* @param fullVirtualName the path of the file to be replaced
* @param file the file to be added to the archive
* @param name the name of the file
* @param archiveOperationMonitor the operation progress monitor
* @return true if and only if the replace was successful
* @return <code>true</code> if the replacement is successful,
* <code>false</code> otherwise
* @since org.eclipse.rse.services 3.0
*/
public boolean replace(String fullVirtualName, File file, String name, ISystemOperationMonitor archiveOperationMonitor);
/**
* Compress the InputStream <code>stream</code> and replace the virtual file
* referred to by <code>fullVirtualName</code> with the compressed stream.
* Pass the name of the new entry as the parameter <code>name</code>, the
* encoding of the entry as <code>encoding</code> and whether or not the entry
* <code>isText</code> or not.
* Compress the InputStream <code>stream</code> and replace the virtual
* file referred to by <code>fullVirtualName</code> with the compressed
* stream. Pass the name of the new entry as the parameter <code>name</code>,
* the encoding of the entry as <code>encoding</code> and whether or not
* the entry <code>isText</code> or not.
*
* @param fullVirtualName the path of the file to be replaced
* @param stream the InputStream to be added as an entry to the archive
* @param name the name of the result virtual file
@ -330,16 +427,21 @@ public interface ISystemArchiveHandler
* @param targetEncoding the encoding of the result file
* @param isText is the file a text file
* @param archiveOperationMonitor the operation progress monitor
* @return true if and only if the replace was successful
* @return <code>true</code> if the replacement is successful,
* <code>false</code> otherwise
* @since org.eclipse.rse.services 3.0
*/
public boolean replace(String fullVirtualName, InputStream stream, String name, String sourceEncoding, String targetEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor);
/**
* Deletes the entry <code>fullVirtualName</code> from the archive, and returns
* whether or not the deletion was successful.
* Deletes the entry <code>fullVirtualName</code> from the archive, and
* returns whether or not the deletion was successful.
*
* @param fullVirtualName the path of the file to be deleted
* @param archiveOperationMonitor the operation progress monitor
* @return true if and only if the replace was successful
* @return <code>true</code> if the deletion is successful,
* <code>false</code> otherwise
* @since org.eclipse.rse.services 3.0
*/
public boolean delete(String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor);
@ -347,107 +449,141 @@ public interface ISystemArchiveHandler
* Renames the entry <code>fullVirtualName</code> to the new name
* <code>newName</code> while still leaving the entry in the same virtual
* directory. Returns true if and only if the rename was successful.
*
* @param fullVirtualName the path of the file to be renamed
* @param archiveOperationMonitor the operation progress monitor
* @return true if and only if the replace was successful
* @return <code>true</code> if the rename is successful,
* <code>false</code> otherwise
* @since org.eclipse.rse.services 3.0
*/
public boolean rename(String fullVirtualName, String newName, ISystemOperationMonitor archiveOperationMonitor);
/**
* Moves the entry <code>fullVirtualName</code> to the location
* specified by <code>destinationVirtualPath</code>, while leaving the entry with
* Moves the entry <code>fullVirtualName</code> to the location specified
* by <code>destinationVirtualPath</code>, while leaving the entry with
* the same name as before.
*
* @param fullVirtualName the path of the file to be renamed
* @param destinationVirtualPath the destination of the file to move to
* @param archiveOperationMonitor the operation progress monitor
* @return true if and only if the replace was successful
* @return <code>true</code> if the move is successful, <code>false</code>
* otherwise
* @since org.eclipse.rse.services 3.0
*/
public boolean move(String fullVirtualName, String destinationVirtualPath, ISystemOperationMonitor archiveOperationMonitor);
/**
* Replaces the full name and path of the entry <code>fullVirtualName</code>
* with the new full name and path <code>newFullVirtualName</code>.
*
* @param fullVirtualName the path of the file to be renamed
* @param newFullVirtualName the full path of the virtual file name
* @param archiveOperationMonitor the operation progress monitor
* @return true if and only if the replace was successful
* @return <code>true</code> if the rename is successful,
* <code>false</code> otherwise
* @since org.eclipse.rse.services 3.0
*/
public boolean fullRename(String fullVirtualName, String newFullVirtualName, ISystemOperationMonitor archiveOperationMonitor);
/**
* Extracts and returns the specified list of virtual files from the archive.
* Extracts and returns the specified list of virtual files from the
* archive.
*
* @param fullNames The list of files to return
* @param archiveOperationMonitor the operation progress monitor
* @return An array of handles to the extracted files. If fullNames has length 0
* then this method returns an array of length 0.
* @return An array of handles to the extracted files. If fullNames has
* length 0 then this method returns an array of length 0.
* @since org.eclipse.rse.services 3.0
*/
public File[] getFiles(String[] fullNames, ISystemOperationMonitor archiveOperationMonitor);
/**
* Creates a new, empty folder in the archive. If parent folders do not exist either, creates them.
* @param fullVirtualName The full name and path of the new folder within the virtual file system.
* Creates a new, empty folder in the archive. If parent folders do not
* exist either, creates them.
*
* @param fullVirtualName The full name and path of the new folder within
* the virtual file system.
* @param archiveOperationMonitor the operation progress monitor
* @return Whether or not the creation was successful.
* @return <code>true</code> if the create operation is successful,
* <code>false</code> otherwise
* @since org.eclipse.rse.services 3.0
*/
public boolean createFolder(String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor);
/**
* Creates a new, empty file in the archive. If parent folders do not exist either, creates them.
* @param fullVirtualName The full name and path of the new file within the virtual file system.
* Creates a new, empty file in the archive. If parent folders do not exist
* either, creates them.
*
* @param fullVirtualName The full name and path of the new file within the
* virtual file system.
* @param archiveOperationMonitor the operation progress monitor
* @return Whether or not the creation was successful.
* @return <code>true</code> if the create operation is successful,
* <code>false</code> otherwise
* @since org.eclipse.rse.services 3.0
*/
public boolean createFile(String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor);
/**
* Gets the archive-type specific standard name for the VirtualChild
* <code>vc</code>. For example, for Zips, if vc is a directory, then
* the standard name must end with a "/".
* Get the archive-type specific standard name for the VirtualChild
* <code>vc</code>. For example, for Zip archives, if vc is a directory,
* then the standard name must end with a "/".
*
* @param vc the archive node to use
* @return the standard name for the node
*/
public String getStandardName(VirtualChild vc);
/**
* Searches for text within a virtual file in this archive.
* A good implementation will not actually extract the file to disk.
* Search for text within a virtual file in this archive. A good
* implementation will not actually extract the file to disk.
*
* @param fullVirtualName the virtual file to search.
* @param matcher the pattern matcher to use.
* @param archiveOperationMonitor the operation progress monitor
* @return an array of match objects corresponding to lines where matches were found.
* Returns an empty array if there are no results.
* @return an array of match objects corresponding to lines where matches
* were found. Returns an empty array if there are no results.
* @since org.eclipse.rse.services 3.0
*/
public SystemSearchLineMatch[] search(String fullVirtualName, SystemSearchStringMatcher matcher, ISystemOperationMonitor archiveOperationMonitor);
/**
* Gets the user-defined comment for a specific entry in the archive.
* Get the user-defined comment for a specific entry in the archive.
*
* @param fullVirtualName The entry who's comment is desired
* @return the comment as a String or "" if there is none
*/
public String getCommentFor(String fullVirtualName);
/**
* Gets the amount of space taken up by a specific entry in the archive
* when it is in compressed form. Compare with getSizeFor(String) which gets
* the size of the entry after it is decompressed.
* Get the amount of space taken up by a specific entry in the archive when
* it is in compressed form. Compare with getSizeFor(String) which gets the
* size of the entry after it is decompressed.
*
* @param fullVirtualName The entry who's compressed size is desired
* @return the compressed size of the specified entry, or 0 if the entry is not
* found. If the archive is not a compression type (ie. tar), return the same as getSizeFor(String).
* @return the compressed size of the specified entry, or 0 if the entry is
* not found. If the archive is not a compression type (ie. tar),
* return the same as getSizeFor(String).
*/
public long getCompressedSizeFor(String fullVirtualName);
/**
* Gets the method used to compress a specific entry in the archive.
* Get the method used to compress a specific entry in the archive.
*
* @param fullVirtualName The entry who's compression method is desired
* @return The compression method of the specified entry, or "" if none.
*/
public String getCompressionMethodFor(String fullVirtualName);
/**
* Get the comment associated with an archive.
*
* @return The comment associated with this archive, or "" if there is none.
*/
public String getArchiveComment();
/**
* Returns the classification for the entry with the given path.
* Get the classification for the entry with the given path.
*
* @param fullVirtualName the virtual name.
* @return the classification.
*/

View file

@ -42,11 +42,11 @@ import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import org.eclipse.rse.internal.services.clientserver.archiveutils.ITarConstants;
import org.eclipse.rse.internal.services.clientserver.archiveutils.SystemArchiveUtil;
import org.eclipse.rse.internal.services.clientserver.archiveutils.TarOutputStream;
import org.eclipse.rse.services.clientserver.ISystemFileTypes;
import org.eclipse.rse.services.clientserver.ISystemOperationMonitor;
import org.eclipse.rse.services.clientserver.SystemReentrantMutex;
@ -675,8 +675,9 @@ public class SystemTarHandler implements ISystemArchiveHandler {
}
}
/**
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#getVirtualChildrenList(ISystemOperationMonitor archiveOperationMonitor)
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#getVirtualChildrenList(org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public VirtualChild[] getVirtualChildrenList(ISystemOperationMonitor archiveOperationMonitor) {
@ -704,8 +705,9 @@ public class SystemTarHandler implements ISystemArchiveHandler {
return children;
}
/**
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#getVirtualChildrenList(java.lang.String, ISystemOperationMonitor)
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#getVirtualChildrenList(java.lang.String, org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public VirtualChild[] getVirtualChildrenList(String parent, ISystemOperationMonitor archiveOperationMonitor) {
parent = ArchiveHandlerManager.cleanUpVirtualPath(parent);
@ -742,8 +744,9 @@ public class SystemTarHandler implements ISystemArchiveHandler {
return children;
}
/**
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#getVirtualChildren(java.lang.String, ISystemOperationMonitor)
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#getVirtualChildren(java.lang.String, org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public VirtualChild[] getVirtualChildren(String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor) {
@ -759,8 +762,9 @@ public class SystemTarHandler implements ISystemArchiveHandler {
return vfs.getChildren(fullVirtualName);
}
/**
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#getVirtualChildFolders(java.lang.String, ISystemOperationMonitor)
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#getVirtualChildFolders(java.lang.String, org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public VirtualChild[] getVirtualChildFolders(String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor) {
@ -776,8 +780,9 @@ public class SystemTarHandler implements ISystemArchiveHandler {
return vfs.getChildrenFolders(fullVirtualName);
}
/**
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#getVirtualFile(java.lang.String, ISystemOperationMonitor)
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#getVirtualFile(java.lang.String, org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public VirtualChild getVirtualFile(String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor) {
@ -806,8 +811,9 @@ public class SystemTarHandler implements ISystemArchiveHandler {
return entry;
}
/**
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#exists(java.lang.String, ISystemOperationMonitor)
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#exists(java.lang.String, org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public boolean exists(String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor) {
@ -842,7 +848,8 @@ public class SystemTarHandler implements ISystemArchiveHandler {
return file;
}
/**
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#getTimeStampFor(java.lang.String)
*/
public long getTimeStampFor(String fullVirtualName) {
@ -862,7 +869,8 @@ public class SystemTarHandler implements ISystemArchiveHandler {
}
}
/**
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#getSizeFor(java.lang.String)
*/
public long getSizeFor(String fullVirtualName) {
@ -925,10 +933,10 @@ public class SystemTarHandler implements ISystemArchiveHandler {
//Need to make sure destination file exists.
if (!destination.exists())
{
File parentFile = destination.getParentFile();
if (!parentFile.exists())
parentFile.mkdirs();
destination.createNewFile();
File parentFile = destination.getParentFile();
if (!parentFile.exists())
parentFile.mkdirs();
destination.createNewFile();
}
outStream = new FileOutputStream(destination);
@ -981,8 +989,9 @@ public class SystemTarHandler implements ISystemArchiveHandler {
return extractVirtualDirectory(fullVirtualName, destinationParent, (File) null, archiveOperationMonitor);
}
/**
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#extractVirtualDirectory(java.lang.String, java.io.File, java.io.File, ISystemOperationMonitor)
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#extractVirtualDirectory(java.lang.String, java.io.File, java.io.File, org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public boolean extractVirtualDirectory(String fullVirtualName, File destinationParent, File destination, ISystemOperationMonitor archiveOperationMonitor) {
@ -1095,8 +1104,9 @@ public class SystemTarHandler implements ISystemArchiveHandler {
return true;
}
/**
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#add(java.io.File, java.lang.String, java.lang.String, ISystemOperationMonitor)
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#add(java.io.File, java.lang.String, java.lang.String, org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public boolean add(File file, String virtualPath, String name, ISystemOperationMonitor archiveOperationMonitor ) {
virtualPath = ArchiveHandlerManager.cleanUpVirtualPath(virtualPath);
@ -1170,11 +1180,11 @@ public class SystemTarHandler implements ISystemArchiveHandler {
}
/**
* Helper method. . . populates <code>found</code> with a
* collapsed list of all nodes in the subtree
* of the file system rooted at <code>parent</code>.
* Helper method. Populates given List <code>found</code> with a collapsed
* list of all nodes in the subtree of the file system rooted at
* <code>parent</code>.
*/
public void listAllFiles(File parent, Vector found) {
public void listAllFiles(File parent, List found) {
File[] children = parent.listFiles();
@ -1188,8 +1198,9 @@ public class SystemTarHandler implements ISystemArchiveHandler {
}
}
/**
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#add(java.io.File[], java.lang.String, java.lang.String[], ISystemOperationMonitor)
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#add(java.io.File[], java.lang.String, java.lang.String[], org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public boolean add(File[] files, String virtualPath, String[] names, ISystemOperationMonitor archiveOperationMonitor) {
@ -1228,65 +1239,65 @@ public class SystemTarHandler implements ISystemArchiveHandler {
}
}
// 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 = getTarOutputStream(outputTempFile);
// 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 = getTarOutputStream(outputTempFile);
// get all the entries in the current tar
VirtualChild[] children = getVirtualChildrenList(archiveOperationMonitor);
// get all the entries in the current tar
VirtualChild[] children = getVirtualChildrenList(archiveOperationMonitor);
// if it is an empty temp file, no need to recreate it
if (children.length != 0) {
boolean isCanceled = createTar(children, outStream, (HashSet)null, archiveOperationMonitor);
if (isCanceled)
{
outStream.close();
if (outputTempFile != null)
{
outputTempFile.delete();
}
return false;
}
}
VirtualChild[] newEntriesAdded = new VirtualChild[numFiles];
// for each new file to add
for (int i = 0; i < numFiles; i++) {
if (archiveOperationMonitor != null && archiveOperationMonitor.isCanceled())
{
outStream.close();
if (outputTempFile != null)
{
outputTempFile.delete();
}
return false;
}
String childVirtualPath = virtualPath + "/" + names[i]; //$NON-NLS-1$
TarEntry newEntry = createTarEntry(files[i], childVirtualPath);
// append the additional entry to the tar file
appendFile(files[i], newEntry, outStream);
// add the new entry to the cache, so that the cache is updated
VirtualChild temp = getVirtualChild(newEntry);
newEntriesAdded[i] = temp;
}
// close output stream
outStream.close();
// replace the current tar file with the new one, and do not update cache since
// we just did
replaceFile(outputTempFile, false);
//Also need to add the new entries into VFS
for (int i = 0; i < numFiles; i++)
// if it is an empty temp file, no need to recreate it
if (children.length != 0) {
boolean isCanceled = createTar(children, outStream, (HashSet)null, archiveOperationMonitor);
if (isCanceled)
{
vfs.addEntry(newEntriesAdded[i]);
outStream.close();
if (outputTempFile != null)
{
outputTempFile.delete();
}
return false;
}
}
VirtualChild[] newEntriesAdded = new VirtualChild[numFiles];
// for each new file to add
for (int i = 0; i < numFiles; i++) {
if (archiveOperationMonitor != null && archiveOperationMonitor.isCanceled())
{
outStream.close();
if (outputTempFile != null)
{
outputTempFile.delete();
}
return false;
}
String childVirtualPath = virtualPath + "/" + names[i]; //$NON-NLS-1$
TarEntry newEntry = createTarEntry(files[i], childVirtualPath);
// append the additional entry to the tar file
appendFile(files[i], newEntry, outStream);
// add the new entry to the cache, so that the cache is updated
VirtualChild temp = getVirtualChild(newEntry);
newEntriesAdded[i] = temp;
}
// close output stream
outStream.close();
// replace the current tar file with the new one, and do not update cache since
// we just did
replaceFile(outputTempFile, false);
//Also need to add the new entries into VFS
for (int i = 0; i < numFiles; i++)
{
vfs.addEntry(newEntriesAdded[i]);
}
}
}
@ -1320,13 +1331,18 @@ public class SystemTarHandler implements ISystemArchiveHandler {
}
/**
* Create a tar file from the given virtual child objects, using the given output stream and omitting
* the children in the given set.
* @param children an array of virtual children from which to create a tar file.
* Create a tar file from the given virtual child objects, using the given
* output stream and omitting the children in the given set.
*
* @param children an array of virtual children from which to create a tar
* file.
* @param outStream the tar output stream to use.
* @param omitChildren the set of names for children that should be omitted from the given array of virtual children.
* @param omitChildren the set of names for children that should be omitted
* from the given array of virtual children.
* @param archiveOperationMonitor the operation progress monitor
* @return <code>true</code> if the operation has been canceled, <code>false</code> otherwise
* @throws IOException if an I/O exception occurs.
* @since org.eclipse.rse.services 3.0
*/
protected boolean createTar(VirtualChild[] children, TarOutputStream outStream, HashSet omitChildren, ISystemOperationMonitor archiveOperationMonitor) throws IOException {
@ -1443,7 +1459,7 @@ public class SystemTarHandler implements ISystemArchiveHandler {
if (file.isDirectory()) {
if (!fullName.endsWith("/")) { //$NON-NLS-1$
fullName = fullName + "/"; //$NON-NLS-1$
fullName = fullName + "/"; //$NON-NLS-1$
}
}
@ -1496,12 +1512,12 @@ public class SystemTarHandler implements ISystemArchiveHandler {
// if security manager successfully created, check permission
// create a file permission to check execute
FilePermission permission = new FilePermission(file.getAbsolutePath(), "execute"); //$NON-NLS-1$
// create a file permission to check execute
FilePermission permission = new FilePermission(file.getAbsolutePath(), "execute"); //$NON-NLS-1$
// this call will throw a SecurityException if permission does not exist
sm.checkPermission(permission);
canExecute = true;
// this call will throw a SecurityException if permission does not exist
sm.checkPermission(permission);
canExecute = true;
}
catch(SecurityException e) {
@ -1537,7 +1553,7 @@ public class SystemTarHandler implements ISystemArchiveHandler {
if (file.isDirectory()) {
if (!fullName.endsWith("/")) { //$NON-NLS-1$
fullName = fullName + "/"; //$NON-NLS-1$
fullName = fullName + "/"; //$NON-NLS-1$
}
}
@ -1743,8 +1759,9 @@ public class SystemTarHandler implements ISystemArchiveHandler {
}
}
/**
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#delete(java.lang.String, ISystemOperationMonitor)
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#delete(java.lang.String, org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public boolean delete(String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor)
{
@ -1754,6 +1771,14 @@ public class SystemTarHandler implements ISystemArchiveHandler {
}
/**
* Delete a virtual object.
*
* @param fullVirtualName virtual path identifying the object
* @param archiveOperationMonitor the operation progress monitor
* @return <code>true</code> if successful, <code>false</code> otherwise
* @since org.eclipse.rse.services 3.0
*/
protected boolean doDelete(String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor) {
File outputTempFile = null;
@ -1836,8 +1861,9 @@ public class SystemTarHandler implements ISystemArchiveHandler {
return false;
}
/**
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#rename(java.lang.String, java.lang.String, ISystemOperationMonitor)
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#rename(java.lang.String, java.lang.String, org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public boolean rename(String fullVirtualName, String newName, ISystemOperationMonitor archiveOperationMonitor) {
fullVirtualName = ArchiveHandlerManager.cleanUpVirtualPath(fullVirtualName);
@ -1860,8 +1886,9 @@ public class SystemTarHandler implements ISystemArchiveHandler {
return resultCode;
}
/**
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#move(java.lang.String, java.lang.String, ISystemOperationMonitor)
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#move(java.lang.String, java.lang.String, org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public boolean move(String fullVirtualName, String destinationVirtualPath, ISystemOperationMonitor archiveOperationMonitor) {
fullVirtualName = ArchiveHandlerManager.cleanUpVirtualPath(fullVirtualName);
@ -2009,13 +2036,19 @@ public class SystemTarHandler implements ISystemArchiveHandler {
}
/**
* Creates a tar file from the given virtual child objects, using the given output stream and renaming entries
* according to hash map entries.
* @param children an array of virtual children from which to create a tar file.
* Creates a tar file from the given virtual child objects, using the given
* output stream and renaming entries according to hash map entries.
*
* @param children an array of virtual children from which to create a tar
* file.
* @param outStream the tar output stream to use.
* @param renameMap a map containing associations between old names and new names. Old names are the keys
* in the map, and the values are the new names.
* @param renameMap a map containing associations between old names and new
* names. Old names are the keys in the map, and the values are
* the new names.
* @param archiveOperationMonitor the operation progress monitor
* @return <code>true</code> if the operation has been canceled, <code>false</code> otherwise.
* @throws IOException if an I/O exception occurs.
* @since org.eclipse.rse.services 3.0
*/
protected boolean createTar(VirtualChild[] children, TarOutputStream outStream, HashMap renameMap, ISystemOperationMonitor archiveOperationMonitor) throws IOException {
@ -2113,8 +2146,9 @@ public class SystemTarHandler implements ISystemArchiveHandler {
return entry;
}
/**
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#getFiles(java.lang.String[], ISystemOperationMonitor)
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#getFiles(java.lang.String[], org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public File[] getFiles(String[] fullNames, ISystemOperationMonitor archiveOperationMonitor) {
@ -2147,8 +2181,9 @@ public class SystemTarHandler implements ISystemArchiveHandler {
return files;
}
/**
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#createFolder(java.lang.String, ISystemOperationMonitor)
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#createFolder(java.lang.String, org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public boolean createFolder(String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor) {
fullVirtualName = ArchiveHandlerManager.cleanUpVirtualPath(fullVirtualName);
@ -2158,8 +2193,9 @@ public class SystemTarHandler implements ISystemArchiveHandler {
return returnCode;
}
/**
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#createFile(java.lang.String, ISystemOperationMonitor)
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#createFile(java.lang.String, org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public boolean createFile(String fullVirtualName, ISystemOperationMonitor archiveOperationMonitor) {
fullVirtualName = ArchiveHandlerManager.cleanUpVirtualPath(fullVirtualName);
@ -2169,10 +2205,14 @@ public class SystemTarHandler implements ISystemArchiveHandler {
}
/**
* Creates a virtual object that does not already exist in the virtual file system.
* Creates an empty file in the tar file.
* Creates a virtual object that does not already exist in the virtual file
* system. Creates an empty file in the tar file.
*
* @param name the name of the virtual object.
* @return <code>true</code> if the object was created successfully, <code>false</code> otherwise.
* @param archiveOperationMonitor the operation progress monitor
* @return <code>true</code> if the object was created successfully,
* <code>false</code> otherwise.
* @since org.eclipse.rse.services 3.0
*/
protected boolean createVirtualObject(String name, ISystemOperationMonitor archiveOperationMonitor) {
@ -2299,12 +2339,12 @@ public class SystemTarHandler implements ISystemArchiveHandler {
// if security manager successfully created, check permission
// create a file permission to check execute
FilePermission permission = new FilePermission(file.getAbsolutePath(), "execute"); //$NON-NLS-1$
// create a file permission to check execute
FilePermission permission = new FilePermission(file.getAbsolutePath(), "execute"); //$NON-NLS-1$
// this call will throw a SecurityException if permission does not exist
sm.checkPermission(permission);
canExecute = true;
// this call will throw a SecurityException if permission does not exist
sm.checkPermission(permission);
canExecute = true;
}
catch(SecurityException e) {
@ -2325,7 +2365,8 @@ public class SystemTarHandler implements ISystemArchiveHandler {
return newEntry;
}
/**
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#getStandardName(org.eclipse.rse.services.clientserver.archiveutils.VirtualChild)
*/
public String getStandardName(VirtualChild vc) {
@ -2337,7 +2378,8 @@ public class SystemTarHandler implements ISystemArchiveHandler {
return vc.fullName;
}
/**
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#create()
*/
public boolean create() {
@ -2408,10 +2450,15 @@ public class SystemTarHandler implements ISystemArchiveHandler {
}
}
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#exists()
*/
public boolean exists()
{
return true;
}
/* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#getCommentFor(java.lang.String)
*/
@ -2447,12 +2494,13 @@ public class SystemTarHandler implements ISystemArchiveHandler {
/**
* Compresses the file <code>file</code> and adds it to the archive,
* saving it in the encoding specified by <code>encoding</code> if
* saving in text mode.
* Places the file in the virtual directory <code>virtualPath</code>. Pass the
* name as the parameter <code>name</code>. If the virtual path does not exist
* in the archive, create it. If <code>file</code> is a directory, copy it and
* its contents into the archive, maintaining the tree structure.
* saving it in the encoding specified by <code>encoding</code> if saving
* in text mode. Places the file in the virtual directory
* <code>virtualPath</code>. Pass the name as the parameter
* <code>name</code>. If the virtual path does not exist in the archive,
* create it. If <code>file</code> is a directory, copy it and its
* contents into the archive, maintaining the tree structure.
*
* @param file the file to be added to the archive
* @param virtualPath the destination of the file
* @param name the name of the result virtual file
@ -2460,6 +2508,7 @@ public class SystemTarHandler implements ISystemArchiveHandler {
* @param registry the file type to use (text or binary)
* @param archiveOperationMonitor the operation progress monitor
* @return true if and only if the add was successful
* @since org.eclipse.rse.services 3.0
*/
public boolean add(File file, String virtualPath, String name,
String encoding, ISystemFileTypes registry, ISystemOperationMonitor archiveOperationMonitor) {
@ -2473,6 +2522,7 @@ public class SystemTarHandler implements ISystemArchiveHandler {
String sourceEncoding, String targetEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor) {
return add(file, virtualPath, name, archiveOperationMonitor);
}
/* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#add(java.io.File[], java.lang.String, java.lang.String[], java.lang.String[], java.lang.String[], boolean[])
*/
@ -2480,6 +2530,7 @@ public class SystemTarHandler implements ISystemArchiveHandler {
String[] sourceEncodings, String[] targetEncodings, boolean[] isTexts, ISystemOperationMonitor archiveOperationMonitor) {
return add(files, virtualPath, names, archiveOperationMonitor);
}
/* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#extractVirtualDirectory(java.lang.String, java.io.File, java.io.File, java.lang.String, boolean)
*/
@ -2487,6 +2538,7 @@ public class SystemTarHandler implements ISystemArchiveHandler {
File destination, String sourceEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor) {
return extractVirtualDirectory(dir, destinationParent, destination, archiveOperationMonitor);
}
/* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#extractVirtualDirectory(java.lang.String, java.io.File, java.lang.String, boolean)
*/
@ -2494,6 +2546,7 @@ public class SystemTarHandler implements ISystemArchiveHandler {
String sourceEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor) {
return extractVirtualDirectory(dir, destinationParent, archiveOperationMonitor);
}
/* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#extractVirtualFile(java.lang.String, java.io.File, java.lang.String, boolean)
*/
@ -2502,7 +2555,8 @@ public class SystemTarHandler implements ISystemArchiveHandler {
return extractVirtualFile(fullVirtualName, destination, archiveOperationMonitor);
}
/**
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#getClassification(java.lang.String)
*/
public String getClassification(String fullVirtualName) {
@ -2551,7 +2605,7 @@ public class SystemTarHandler implements ISystemArchiveHandler {
String qualifiedClassName = parser.getQualifiedClassName();
if (qualifiedClassName != null) {
type = type + ":" + qualifiedClassName; //$NON-NLS-1$
type = type + ":" + qualifiedClassName; //$NON-NLS-1$
}
type = type + ")"; //$NON-NLS-1$
@ -2613,12 +2667,13 @@ public class SystemTarHandler implements ISystemArchiveHandler {
}
/**
* Get the tar output stream for a given file.
* This method can be overridden by subclass to return compressed output steam if needed.
* Get the tar output stream for a given file. This method can be overridden
* 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
* @since 3.0
* @throws FileNotFoundException when the output file doesn't exist
* @since org.eclipse.rse.services 3.0
*/
protected TarOutputStream getTarOutputStream(File outputFile) throws FileNotFoundException {
TarOutputStream outStream = new TarOutputStream(new FileOutputStream(outputFile));

View file

@ -16,7 +16,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.GZIPOutputStream;
import org.eclipse.rse.internal.services.clientserver.archiveutils.TarOutputStream;
import org.eclipse.rse.internal.services.clientserver.archiveutils.TgzFile;
/**

View file

@ -13,15 +13,16 @@
*
* Contributors:
* {Name} (company) - description of contribution.
* Xuan Chen (IBM) - [192741] [Archives] Move a folder from within an Archive doesn't work if > 1 level deep
* Xuan Chen (IBM) - [194293] [Local][Archives] Saving file second time in an Archive Errors
* Xuan Chen (IBM) - [181784] [archivehandlers] zipped text files have unexpected contents
* Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
* Xuan Chen (IBM) - [209828] Need to move the Create operation to a job.
* Xuan Chen (IBM) - [191370] [dstore] Supertransfer zip not deleted when cancelling copy
* Xuan Chen (IBM) - [214251] [archive] "Last Modified Time" changed for all virtual files/folders if rename/paste/delete of one virtual file.
* Xuan Chen (IBM) - [214786] [regression][archive]rename a virtual directory does not work properly
* Xuan Chen (IBM) - [191370] [dstore] Supertransfer zip not deleted when cancelling copy
* Xuan Chen (IBM) - [192741] [Archives] Move a folder from within an Archive doesn't work if > 1 level deep
* Xuan Chen (IBM) - [194293] [Local][Archives] Saving file second time in an Archive Errors
* Xuan Chen (IBM) - [181784] [Archives] zipped text files have unexpected contents
* Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
* Xuan Chen (IBM) - [209828] Need to move the Create operation to a job.
* Xuan Chen (IBM) - [191370] [dstore] Supertransfer zip not deleted when canceling copy
* Xuan Chen (IBM) - [214251] [archive] "Last Modified Time" changed for all virtual files/folders if rename/paste/delete of one virtual file.
* Xuan Chen (IBM) - [214786] [regression][archive]rename a virtual directory does not work properly
* Xuan Chen (IBM) - [191370] [dstore] Supertransfer zip not deleted when canceling copy
* Martin Oberhuber (Wind River) - [cleanup] Add API "since" tags
*******************************************************************************/
package org.eclipse.rse.services.clientserver.archiveutils;
@ -56,8 +57,8 @@ import org.eclipse.rse.services.clientserver.search.SystemSearchStringMatcher;
/**
* @author mjberger
* Implements an ISystemArchiveHandler for ZIP files.
* @author mjberger
*/
public class SystemZipHandler implements ISystemArchiveHandler
{
@ -104,6 +105,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
protected File _file; // The underlying file associated with this handler.
protected long _vfsLastModified; // The timestamp of the file that the virtual file system reflects.
protected boolean _exists; // Whether or not the zipfile "exists" (in order to exist, must be uncorrupted too)
/** @since org.eclipse.rse.services 3.0 */
protected SystemReentrantMutex _mutex;
/**
@ -131,7 +133,6 @@ public class SystemZipHandler implements ISystemArchiveHandler
/**
* Builds the virtual file system tree out of the entries in
* the zipfile.
*
*/
protected void buildTree()
{
@ -145,8 +146,8 @@ public class SystemZipHandler implements ISystemArchiveHandler
}
/**
* Update the virtual file system tree after rename operation
*
* Update the virtual file system tree after rename operation.
* @since org.eclipse.rse.services 3.0
*/
protected void updateTreeAfterRename(HashMap newOldName, VirtualChild[] renameList)
{
@ -251,7 +252,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
recursivePopulate(nextChild.path, nextChild);
}
else // key has been encountered before, no need to recursively
// populate the subdirectories
// populate the subdirectories
{
HashMap hm = (HashMap) _virtualFS.get(nextChild.path);
hm.put(nextChild.name, nextChild);
@ -264,6 +265,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
* the virtual path of the parameter, we can deduce what the ancestors
* of the leaves are, and populate the tree from there.
* @param next The ZipEntry from which the branch will be built.
* @since org.eclipse.rse.services 3.0
*/
protected void fillBranchAfterRename(ZipEntry next, String oldName)
{
@ -343,7 +345,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
//It is the directory itself, remove the hashmap.
_virtualFS.remove(pathNameToSearchInVFS);
}
*/
*/
}
if (null == nextChild)
@ -381,7 +383,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
populate(nextChild.path, nextChild);
}
else // key has been encountered before, no need to recursively
// populate the subdirectories
// populate the subdirectories
{
HashMap hm = (HashMap) _virtualFS.get(nextChild.path);
hm.put(nextChild.name, nextChild);
@ -440,6 +442,9 @@ public class SystemZipHandler implements ISystemArchiveHandler
}
/**
* @since org.eclipse.rse.services 3.0
*/
protected void populate(String key, VirtualChild value)
{
// base case 1: key has been encountered before, finish recursing
@ -496,6 +501,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
/**
* Same as getVirtualChildrenList(), but you can choose whether
* to leave the zip file open or closed upon return.
* @since org.eclipse.rse.services 3.0
*/
public VirtualChild[] getVirtualChildrenList(boolean closeZipFile, ISystemOperationMonitor archiveOperationMonitor)
{
@ -553,6 +559,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
/**
* Same as getVirtualChildrenList(String parent) but you can choose whether
* or not you want to leave the zipfile open after return.
* @since org.eclipse.rse.services 3.0
*/
public VirtualChild[] getVirtualChildrenList(String parent, boolean closeZipFile, ISystemOperationMonitor archiveOperationMonitor)
{
@ -808,6 +815,15 @@ public class SystemZipHandler implements ISystemArchiveHandler
return getSizeFor(fullVirtualName, true);
}
/**
* Same as {@link #getSizeFor(String)} but allows to specify whether to
* close the zip file or not.
*
* @param fullVirtualName absolute virtual path to the node to inspect
* @param closeZipFile <code>true</code> if the zip file should be closed
* @return the uncompressed size of the node requested.
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#getSizeFor(java.lang.String)
*/
public long getSizeFor(String fullVirtualName, boolean closeZipFile)
{
if (!_exists) return 0;
@ -850,6 +866,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
/**
* Same as extractVirtualFile(String fullVirtualName, File destination) but you can choose whether
* or not you want to leave the zipfile open after return.
* @since org.eclipse.rse.services 3.0
*/
public boolean extractVirtualFile(String fullVirtualName, File destination, boolean closeZipFile, String sourceEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor)
{
@ -884,13 +901,13 @@ public class SystemZipHandler implements ISystemArchiveHandler
if (!destination.exists())
{
File parentFile = destination.getParentFile();
if (!parentFile.exists())
parentFile.mkdirs();
destination.createNewFile();
File parentFile = destination.getParentFile();
if (!parentFile.exists())
parentFile.mkdirs();
destination.createNewFile();
}
BufferedOutputStream writer = new BufferedOutputStream(
new FileOutputStream(destination));
new FileOutputStream(destination));
byte[] buf = new byte[1024];
int numRead = reader.read(buf);
@ -912,29 +929,29 @@ public class SystemZipHandler implements ISystemArchiveHandler
}
writer.close();
reader.close();
}
destination.setLastModified(entry.getTime());
}
destination.setLastModified(entry.getTime());
if (closeZipFile) closeZipFile();
return true;
}
catch (IOException e)
{
if (_virtualFS.containsKey(fullVirtualName))
{
destination.delete();
destination.mkdirs();
destination.setLastModified(_file.lastModified());
if (closeZipFile) closeZipFile();
return true;
}
catch (IOException e)
{
if (_virtualFS.containsKey(fullVirtualName))
{
destination.delete();
destination.mkdirs();
destination.setLastModified(_file.lastModified());
if (closeZipFile) closeZipFile();
return true;
}
System.out.println(e.getMessage());
if (closeZipFile) closeZipFile();
return false;
}
finally
{
releaseMutex(mutexLockStatus);
}
System.out.println(e.getMessage());
if (closeZipFile) closeZipFile();
return false;
}
finally
{
releaseMutex(mutexLockStatus);
}
}
else
@ -967,6 +984,10 @@ public class SystemZipHandler implements ISystemArchiveHandler
return extractVirtualDirectory(dir, destinationParent, destination, SystemEncodingUtil.ENCODING_UTF_8, false, archiveOperationMonitor);
}
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#extractVirtualDirectory(java.lang.String, java.io.File, java.io.File, java.lang.String, boolean, org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public boolean extractVirtualDirectory(String dir, File destinationParent, File destination, String sourceEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor)
{
if (!_exists) return false;
@ -1039,8 +1060,8 @@ public class SystemZipHandler implements ISystemArchiveHandler
}
if (!topFilePath.endsWith(lastPortionOfDir))
{
rename(dir, topFile.getName(), archiveOperationMonitor);
dir = topFile.getName();
rename(dir, topFile.getName(), archiveOperationMonitor);
dir = topFile.getName();
}
VirtualChild[] newChildren = getVirtualChildrenList(dir, archiveOperationMonitor);
@ -1066,7 +1087,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
{
nextFile = new File(destination, nextFile.getName());
}
*/
*/
if (!nextFile.exists())
{
if (newChildren[i].isDirectory)
@ -1084,11 +1105,11 @@ public class SystemZipHandler implements ISystemArchiveHandler
boolean success = false;
if (newChildren[i].isDirectory)
{
success = extractVirtualFile(newChildren[i].fullName + '/', nextFile, sourceEncoding, isText, archiveOperationMonitor);
success = extractVirtualFile(newChildren[i].fullName + '/', nextFile, sourceEncoding, isText, archiveOperationMonitor);
}
else
{
success = extractVirtualFile(newChildren[i].fullName, nextFile, sourceEncoding, isText, archiveOperationMonitor);
success = extractVirtualFile(newChildren[i].fullName, nextFile, sourceEncoding, isText, archiveOperationMonitor);
}
if (!success) return false;
}
@ -1096,6 +1117,13 @@ public class SystemZipHandler implements ISystemArchiveHandler
return true;
}
/**
* Create an empty file, also creating parent folders if necessary.
*
* @param file An abstract file handle to create physically.
* @return <code>true</code> if successful, <code>false</code>
* otherwise.
*/
protected boolean createFile(File file)
{
try
@ -1132,6 +1160,10 @@ public class SystemZipHandler implements ISystemArchiveHandler
return add(file, virtualPath, name, SystemEncodingUtil.ENCODING_UTF_8, SystemEncodingUtil.ENCODING_UTF_8, false, archiveOperationMonitor);
}
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#add(java.io.InputStream, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean, org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public boolean add(InputStream stream, String virtualPath, String name, String sourceEncoding, String targetEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor)
{
if (!_exists) return false;
@ -1158,7 +1190,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
// Open a new tempfile which will be our destination for the new zip
outputTempFile = new File(_file.getAbsolutePath() + "temp"); //$NON-NLS-1$
ZipOutputStream dest = new ZipOutputStream(
new FileOutputStream(outputTempFile));
new FileOutputStream(outputTempFile));
dest.setMethod(ZipOutputStream.DEFLATED);
// get all the entries in the old zip
@ -1228,6 +1260,10 @@ public class SystemZipHandler implements ISystemArchiveHandler
return add(files, virtualPath, names, encodings, encodings, isTexts, true, archiveOperationMonitor);
}
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#add(java.io.File[], java.lang.String, java.lang.String[], java.lang.String[], java.lang.String[], boolean[], org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public boolean add(File[] files, String virtualPath, String[] names, String[] sourceEncodings, String[] targetEncodings, boolean[] isText, ISystemOperationMonitor archiveOperationMonitor)
{
return add(files, virtualPath, names, sourceEncodings, targetEncodings, isText, true, archiveOperationMonitor);
@ -1237,6 +1273,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
/**
* Same as add(File[] files, String virtualPath, String[] names, String[] encodings) but you can choose whether
* or not you want to leave the zipfile open after return.
* @since org.eclipse.rse.services 3.0
*/
public boolean add(File[] files, String virtualPath, String[] names, String[] sourceEncodings, String[] targetEncodings, boolean[] isText, boolean closeZipFile, ISystemOperationMonitor archiveOperationMonitor)
{
@ -1273,7 +1310,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
// Open a new tempfile which will be our destination for the new zip
outputTempFile = new File(_file.getAbsolutePath() + "temp"); //$NON-NLS-1$
ZipOutputStream dest = new ZipOutputStream(
new FileOutputStream(outputTempFile));
new FileOutputStream(outputTempFile));
dest.setMethod(ZipOutputStream.DEFLATED);
// get all the entries in the old zip
@ -1301,7 +1338,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
ZipEntry[] newEntriesAdded = new ZipEntry[numFiles];
for (int i = 0; i < numFiles; i++)
{
if (archiveOperationMonitor != null && archiveOperationMonitor.isCanceled())
if (archiveOperationMonitor != null && archiveOperationMonitor.isCanceled())
{
//the operation has been canceled
dest.close();
@ -1347,17 +1384,18 @@ public class SystemZipHandler implements ISystemArchiveHandler
}
/**
* Helper method. . . populates <code>found</code> with a
* collapsed list of all nodes in the subtree
* of the file system rooted at <code>parent</code>.
* Helper method. populates <code>found</code> with a collapsed list of
* all nodes in the subtree of the file system rooted at <code>parent</code>.
*
* @since org.eclipse.rse.services 3.0
*/
public static boolean listAllFiles(File parent, HashSet found, ISystemOperationMonitor archiveOperationMonitor)
{
File[] children = parent.listFiles();
if (children == null) // DKM - 56031, no authority on parent yields null
{
found.remove(parent);
return false;
found.remove(parent);
return false;
}
for (int i = 0; i < children.length; i++)
{
@ -1368,14 +1406,14 @@ public class SystemZipHandler implements ISystemArchiveHandler
}
if (!found.contains(children[i])) // prevent infinite loops due to symlinks
{
if (children[i].canRead())
{
found.add(children[i]);
if (children[i].isDirectory())
if (children[i].canRead())
{
found.add(children[i]);
if (children[i].isDirectory())
{
listAllFiles(children[i], found, archiveOperationMonitor);
listAllFiles(children[i], found, archiveOperationMonitor);
}
}
}
}
}
@ -1391,6 +1429,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
* @param omitChildren The set of names of children to omit when creating
* the zipfile. Null or empty set if there are no omissions.
* @throws IOException in case of a file I/O error
* @since org.eclipse.rse.services 3.0
*/
protected boolean recreateZipDeleteEntries(VirtualChild[] vcList, ZipOutputStream dest, HashSet omitChildren, ISystemOperationMonitor archiveOperationMonitor) throws IOException
{
@ -1424,7 +1463,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
}
ZipEntry nextEntry = safeGetEntry(vcList[i].fullName);
BufferedInputStream source = new BufferedInputStream(
_zipfile.getInputStream(nextEntry));
_zipfile.getInputStream(nextEntry));
nextEntry.setCompressedSize(-1);
dest.putNextEntry(nextEntry);
byte[] buf = new byte[1024];
@ -1449,6 +1488,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
* children are to be recreated
* @param names HashMap maps the full path of a virtual file to the entry in the archive file
* @throws IOException
* @since org.eclipse.rse.services 3.0
*/
protected boolean recreateZipRenameEntries(VirtualChild[] vcList, ZipOutputStream dest, HashMap names, ISystemOperationMonitor archiveOperationMonitor) throws IOException
{
@ -1486,7 +1526,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
continue;
}
BufferedInputStream source = new BufferedInputStream(
_zipfile.getInputStream(nextEntry));
_zipfile.getInputStream(nextEntry));
newEntry.setCompressedSize(-1);
dest.putNextEntry(newEntry);
byte[] buf = new byte[1024];
@ -1530,7 +1570,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
if (!file.isDirectory())
{
BufferedInputStream source = new BufferedInputStream(
new FileInputStream(file));
new FileInputStream(file));
byte[] buf = new byte[1024];
int numRead = source.read(buf);
@ -1538,10 +1578,10 @@ public class SystemZipHandler implements ISystemArchiveHandler
long totalRead = 0;
while (numRead > 0 && totalRead < fileSize)
{
totalRead += numRead;
totalRead += numRead;
if (isText)
{
// DKM - if you don't specify numRead here, then buf will get picked up wiht extra bytes from b4!!!!
// DKM - if you don't specify numRead here, then buf will get picked up wiht extra bytes from b4!!!!
String bufString = new String(buf, 0, numRead, sourceEncoding);
byte[] convertedBuf = bufString.getBytes(targetEncoding);
int newSize = convertedBuf.length;
@ -1556,11 +1596,11 @@ public class SystemZipHandler implements ISystemArchiveHandler
long deltaLeft = fileSize - totalRead;
if (deltaLeft > 1024)
{
numRead = source.read(buf, 0, (int)maxRead);
numRead = source.read(buf, 0, (int)maxRead);
}
else
{
numRead = source.read(buf, 0, (int)deltaLeft);
numRead = source.read(buf, 0, (int)deltaLeft);
}
}
@ -1591,10 +1631,10 @@ public class SystemZipHandler implements ISystemArchiveHandler
long totalRead = 0;
while (numRead > 0 && source.available() > 0)
{
totalRead += numRead;
totalRead += numRead;
if (isText)
{
// DKM - if you don't specify numRead here, then buf will get picked up wiht extra bytes from b4!!!!
// DKM - if you don't specify numRead here, then buf will get picked up wiht extra bytes from b4!!!!
String bufString = new String(buf, 0, numRead, sourceEncoding);
byte[] convertedBuf = bufString.getBytes(targetEncoding);
int newSize = convertedBuf.length;
@ -1609,11 +1649,11 @@ public class SystemZipHandler implements ISystemArchiveHandler
long deltaLeft = source.available();
if (deltaLeft > 1024)
{
numRead = source.read(buf, 0, (int)maxRead);
numRead = source.read(buf, 0, (int)maxRead);
}
else
{
numRead = source.read(buf, 0, (int)deltaLeft);
numRead = source.read(buf, 0, (int)deltaLeft);
}
}
@ -1652,6 +1692,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
/**
* Same as delete(String fullVirtualName) but you can choose whether
* or not you want to leave the zipfile open after return.
* @since org.eclipse.rse.services 3.0
*/
public boolean delete(String fullVirtualName, boolean closeZipFile, ISystemOperationMonitor archiveOperationMonitor)
{
@ -1683,7 +1724,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
// Open a new tempfile which will be our destination for the new zip
outputTempFile = new File(_file.getAbsolutePath() + "temp"); //$NON-NLS-1$
ZipOutputStream dest = new ZipOutputStream(
new FileOutputStream(outputTempFile));
new FileOutputStream(outputTempFile));
dest.setMethod(ZipOutputStream.DEFLATED);
// get all the entries in the old zip
@ -1783,6 +1824,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
/**
* Same as replace(String fullVirtualName, File file, String name) but you can choose whether
* or not you want to leave the zipfile open after return.
* @since org.eclipse.rse.services 3.0
*/
public boolean replace(String fullVirtualName, File file, String name, boolean closeZipFile, ISystemOperationMonitor archiveOperationMonitor)
{
@ -1806,7 +1848,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
// Open a new tempfile which will be our destination for the new zip
outputTempFile = new File(_file.getAbsolutePath() + "temp"); //$NON-NLS-1$
ZipOutputStream dest = new ZipOutputStream(
new FileOutputStream(outputTempFile));
new FileOutputStream(outputTempFile));
dest.setMethod(ZipOutputStream.DEFLATED);
// get all the entries in the old zip
VirtualChild[] vcList = getVirtualChildrenList(false, archiveOperationMonitor);
@ -1861,6 +1903,10 @@ public class SystemZipHandler implements ISystemArchiveHandler
}
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#replace(java.lang.String, java.io.InputStream, java.lang.String, java.lang.String, java.lang.String, boolean, org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public boolean replace(String fullVirtualName, InputStream stream, String name, String sourceEncoding, String targetEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor)
{
if (!_exists) return false;
@ -1880,7 +1926,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
// Open a new tempfile which will be our destination for the new zip
outputTempFile = new File(_file.getAbsolutePath() + "temp"); //$NON-NLS-1$
ZipOutputStream dest = new ZipOutputStream(
new FileOutputStream(outputTempFile));
new FileOutputStream(outputTempFile));
dest.setMethod(ZipOutputStream.DEFLATED);
// get all the entries in the old zip
VirtualChild[] vcList = getVirtualChildrenList(false, archiveOperationMonitor);
@ -1938,6 +1984,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
/**
* Same as fullRename(String fullVirtualName, String newFullVirtualName) but you can choose whether
* or not you want to leave the zipfile open after return.
* @since org.eclipse.rse.services 3.0
*/
public boolean fullRename(String fullVirtualName, String newFullVirtualName, boolean closeZipFile, ISystemOperationMonitor archiveOperationMonitor)
{
@ -1961,7 +2008,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
// Open a new tempfile which will be our destination for the new zip
outputTempFile = new File(_file.getAbsolutePath() + "temp"); //$NON-NLS-1$
ZipOutputStream dest = new ZipOutputStream(
new FileOutputStream(outputTempFile));
new FileOutputStream(outputTempFile));
dest.setMethod(ZipOutputStream.DEFLATED);
// get all the entries in the old zip
VirtualChild[] vcList = getVirtualChildrenList(false, archiveOperationMonitor);
@ -1999,7 +2046,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
names.put(fullVirtualName + "/", newFullVirtualName + "/"); //$NON-NLS-1$ //$NON-NLS-2$
}
catch (IOException e) {}
*/
*/
}
else
{
@ -2146,6 +2193,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
* created will be a folder if and only if
* <code>name</code> ends in a "/".
* @return Whether the creation was successful or not.
* @since org.eclipse.rse.services 3.0
*/
protected boolean createVirtualObject(String name, boolean closeZipFile, ISystemOperationMonitor archiveOperationMonitor)
{
@ -2172,7 +2220,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
// Open a new tempfile which will be our destination for the new zip
outputTempFile = new File(_file.getAbsolutePath() + "temp"); //$NON-NLS-1$
ZipOutputStream dest = new ZipOutputStream(
new FileOutputStream(outputTempFile));
new FileOutputStream(outputTempFile));
dest.setMethod(ZipOutputStream.DEFLATED);
// get all the entries in the old zip
VirtualChild[] vcList = getVirtualChildrenList(false, archiveOperationMonitor);
@ -2255,6 +2303,10 @@ public class SystemZipHandler implements ISystemArchiveHandler
return new ZipEntry(name);
}
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#getStandardName(org.eclipse.rse.services.clientserver.archiveutils.VirtualChild)
*/
public String getStandardName(VirtualChild vc)
{
if (vc.isDirectory) return vc.fullName + "/"; //$NON-NLS-1$
@ -2300,6 +2352,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
* If the mod-times of the underlying zip file and the file used to
* create the virtualFS are different, update the virtualFS.
* @return whether or not the op was successful.
* @since org.eclipse.rse.services 3.0
*/
protected boolean updateVirtualFSIfNecessary(ISystemOperationMonitor archiveOperationMonitor)
{
@ -2351,13 +2404,17 @@ public class SystemZipHandler implements ISystemArchiveHandler
return entry;
}
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#create()
*/
public boolean create()
{
try
{
// The zipfile is our destination
ZipOutputStream dest = new ZipOutputStream(
new FileOutputStream(_file));
new FileOutputStream(_file));
dest.setMethod(ZipOutputStream.DEFLATED);
VirtualChild[] vcList = new VirtualChild[0];
@ -2386,6 +2443,10 @@ public class SystemZipHandler implements ISystemArchiveHandler
return true;
}
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#search(java.lang.String, org.eclipse.rse.services.clientserver.search.SystemSearchStringMatcher, org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public SystemSearchLineMatch[] search(String fullVirtualName, SystemSearchStringMatcher matcher, ISystemOperationMonitor archiveOperationMonitor)
{
@ -2444,9 +2505,13 @@ public class SystemZipHandler implements ISystemArchiveHandler
}
}
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#exists()
*/
public boolean exists()
{
return _exists;
return _exists;
}
/* (non-Javadoc)
@ -2555,6 +2620,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
}
else return ""; //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.archiveutils.ISystemArchiveHandler#getArchiveComment()
*/
@ -2634,7 +2700,7 @@ public class SystemZipHandler implements ISystemArchiveHandler
String qualifiedClassName = parser.getQualifiedClassName();
if (qualifiedClassName != null) {
type = type + ":" + qualifiedClassName; //$NON-NLS-1$
type = type + ":" + qualifiedClassName; //$NON-NLS-1$
}
type = type + ")"; //$NON-NLS-1$
@ -2643,6 +2709,10 @@ public class SystemZipHandler implements ISystemArchiveHandler
return type;
}
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#add(java.io.File, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.eclipse.rse.services.clientserver.ISystemFileTypes, org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public boolean add(File file, String virtualPath, String name, String sourceEncoding, String targetEncoding, ISystemFileTypes registry, ISystemOperationMonitor archiveOperationMonitor)
{
if (!_exists)
@ -2721,6 +2791,10 @@ public class SystemZipHandler implements ISystemArchiveHandler
}
}
/*
* (non-Javadoc)
* @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#add(java.io.File, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean, org.eclipse.rse.services.clientserver.ISystemOperationMonitor)
*/
public boolean add(File file, String virtualPath, String name, String sourceEncoding, String targetEncoding, boolean isText, ISystemOperationMonitor archiveOperationMonitor)
{
if (!_exists)

View file

@ -12,16 +12,16 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* {Name} (company) - description of contribution.
* Xuan Chen (IBM) - [api] SystemTarHandler has inconsistent API
* Martin Oberhuber (Wind River) - [cleanup] Move from internal to fix API leakage
*******************************************************************************/
package org.eclipse.rse.internal.services.clientserver.archiveutils;
package org.eclipse.rse.services.clientserver.archiveutils;
import java.io.IOException;
import java.io.OutputStream;
import org.eclipse.rse.services.clientserver.archiveutils.TarEntry;
import org.eclipse.rse.internal.services.clientserver.archiveutils.ITarConstants;
/**
* This class implements an output stream filter for writing files in the

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 IBM Corporation and others.
* Copyright (c) 2006, 2008 IBM Corporation and others.
* 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
@ -12,7 +12,7 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* {Name} (company) - description of contribution.
* Martin Oberhuber (Wind River) - [cleanup] add API "since" tags
*******************************************************************************/
package org.eclipse.rse.services.clientserver.processes;
@ -55,6 +55,7 @@ public interface ISystemProcessRemoteConstants
public static final char STATE_ZOS_SWAPPEDOUT = 'I';
public static final char STATE_ZOS_PTHREADCREATED = 'J';
public static final char STATE_ZOS_OTHERKERNELWAIT = 'K';
/** @since 3.0 renamed from STATE_ZOS_CANCELLED */
public static final char STATE_ZOS_CANCELED = 'L';
public static final char STATE_ZOS_MULTITHREAD = 'M';
public static final char STATE_ZOS_MEDIUMWEIGHTTHREAD = 'N';
@ -94,6 +95,7 @@ public interface ISystemProcessRemoteConstants
public static final int STATE_ZOS_SWAPPEDOUT_INDEX = 18;
public static final int STATE_ZOS_PTHREADCREATED_INDEX = 19;
public static final int STATE_ZOS_OTHERKERNELWAIT_INDEX = 20;
/** @since 3.0 renamed from STATE_ZOS_CANCELLED_INDEX */
public static final int STATE_ZOS_CANCELED_INDEX = 21;
public static final int STATE_ZOS_MULTITHREAD_INDEX = 22;
public static final int STATE_ZOS_MEDIUMWEIGHTTHREAD_INDEX = 23;

View file

@ -16,12 +16,13 @@
* Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem
* Martin Oberhuber (Wind River) - [199548] Avoid touching files on setReadOnly() if unnecessary
* Martin Oberhuber (Wind River) - [204710] Update Javadoc to mention that getUserHome() may return null
* David McKnight (IBM) - [207178] changing list APIs for file service and subsystems
* David McKnight (IBM) - [162195] new APIs for upload multi and download multi
* David McKnight (IBM) - [209552] API changes to use multiple and getting rid of deprecated
* David McKnight (IBM) - [210109] store constants in IFileService rather than IFileServiceConstants
* Kevin Doyle (IBM) - [208778] new API getOutputSteam for getting an output stream in append mode
* David McKnight (IBM) - [209704] added supportsEncodingConversion()
* David McKnight (IBM) - [207178] changing list APIs for file service and subsystems
* David McKnight (IBM) - [162195] new APIs for upload multi and download multi
* David McKnight (IBM) - [209552] API changes to use multiple and getting rid of deprecated
* David McKnight (IBM) - [210109] store constants in IFileService rather than IFileServiceConstants
* Kevin Doyle (IBM) - [208778] new API getOutputSteam for getting an output stream in append mode
* David McKnight (IBM) - [209704] added supportsEncodingConversion()
* Martin Oberhuber (Wind River) - [cleanup] Fix API since tags
*******************************************************************************/
package org.eclipse.rse.services.files;
@ -57,71 +58,84 @@ public interface IFileService extends IService
{
/**
* Query constant (bit mask value 1) which indicates that a query should be
* on files. The filter(s) passed into the list methods will produce a subset
* of files matching the filter(s).
* on files. The filter(s) passed into the list methods will produce a
* subset of files matching the filter(s).
*
* This constant is passed into the IFileService list calls. Implementors of
* IFileService make use of this to determine what to query and what to return
* from the query.
* This constant is passed into the IFileService list calls. Implementors of
* IFileService make use of this to determine what to query and what to
* return from the query.
*
* @see IFileService#list(String,String,int,IProgressMonitor)
* @see IFileService#listMultiple(String[],String[],int,IProgressMonitor)
* @see IFileService#listMultiple(String[],String[],int[],IProgressMonitor)
*
* @since org.eclipse.rse.services 3.0
*/
public static final int FILE_TYPE_FILES = 0x1;
/**
* Query constant (bit mask value 2) which indicates that a query should be
* on folders. The filter(s) passed into the list methods will produce a subset
* of folders matching the filter(s).
* on folders. The filter(s) passed into the list methods will produce a
* subset of folders matching the filter(s).
*
* This constant is passed into the IFileService list calls. Implementors of
* IFileService make use of this to determine what to query and what to return
* from the query.
* This constant is passed into the IFileService list calls. Implementors of
* IFileService make use of this to determine what to query and what to
* return from the query.
*
* @see IFileService#list(String,String,int,IProgressMonitor)
* @see IFileService#listMultiple(String[],String[],int,IProgressMonitor)
* @see IFileService#listMultiple(String[],String[],int[],IProgressMonitor)
*
* @since org.eclipse.rse.services 3.0
*/
public static final int FILE_TYPE_FOLDERS = 0x2;
/**
* Query constant (bit mask value 0) which indicates that a query should produce
* folders and files. The filter(s) passed into the list methods will produce a
* subset of files matching the filter(s) and all the folders.
* Note that only files are filtered and all folders are returned when this is used.
* Query constant (bit mask value 0) which indicates that a query should
* produce folders and files. The filter(s) passed into the list methods
* will produce a subset of files matching the filter(s) and all the
* folders. Note that only files are filtered and all folders are returned
* when this is used.
*
* This constant is passed into the IFileService list calls. Implementors of
* IFileService make use of this to determine what to query and what to return
* from the query.
* This constant is passed into the IFileService list calls. Implementors of
* IFileService make use of this to determine what to query and what to
* return from the query.
*
* @see IFileService#list(String,String,int,IProgressMonitor)
* @see IFileService#listMultiple(String[],String[],int,IProgressMonitor)
* @see IFileService#listMultiple(String[],String[],int[],IProgressMonitor)
*
* @since org.eclipse.rse.services 3.0
*/
public static final int FILE_TYPE_FILES_AND_FOLDERS = 0x0;
/**
* Options constant (value 1 &lt;&lt;0) for specifying a stream
* that will append data to a file.
* Options constant (value 1 &lt;&lt;0) for specifying a stream that will
* append data to a file.
*
* @see IFileService#getOutputStream(String, String, int, IProgressMonitor)
*
* @since org.eclipse.rse.services 3.0
*/
public static final int APPEND = 1 << 0;
/**
* Options constant (value 2 &lt;&lt;0) for specifying that a file
* is Text instead of the default Binary.
* Options constant (value 2 &lt;&lt;0) for specifying that a file is Text
* instead of the default Binary.
*
* In Text mode, encoding conversions and line end conversions can be
* performed on the stream.
*
* @see IFileService#getOutputStream(String, String, int, IProgressMonitor)
*
* @since org.eclipse.rse.services 3.0
*/
public static final int TEXT_MODE = 2 << 0;
/**
* Options constant (value 0) to indicate that no bit options are set.
*
* @since org.eclipse.rse.services 3.0
*/
public static final int NONE = 0;
@ -172,6 +186,8 @@ public interface IFileService extends IService
* @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the
* {@link RemoteFileException} family.
*
* @since org.eclipse.rse.services 3.0
*/
public boolean uploadMultiple(File[] localFiles, String[] remoteParents, String[] remoteFiles, boolean[] isBinary, String[] srcEncodings, String[] hostEncodings, IProgressMonitor monitor) throws SystemMessageException;
@ -194,109 +210,136 @@ public interface IFileService extends IService
/**
* Copy files from the remote file system to the local system.
*
* @param remoteParents - string designating the remote parents.
* @param remoteFiles - Strings designating the remote files residing in the parents.
* @param localFiles - The files that are to be written. If the files exists they are
* overwritten.
* @param remoteFiles - Strings designating the remote files residing in the
* parents.
* @param localFiles - The files that are to be written. If the files exists
* they are overwritten.
* @param isBinary - indicates whether the files are text on binary
* @param hostEncodings - the encodings on the host (if text)
* @param monitor the monitor for this potentially long running operation
* @return true if the files were copied from the remote system.
* @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the
* {@link RemoteFileException} family.
* @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the {@link RemoteFileException} family.
*
* @since org.eclipse.rse.services 3.0
*/
public boolean downloadMultiple(String[] remoteParents, String[] remoteFiles, File[] localFiles, boolean[] isBinary, String[] hostEncodings, IProgressMonitor monitor) throws SystemMessageException;
/**
* Get an abstract remote file handle for a specified path.
*
* @param remoteParent
* @param name
* @param monitor the monitor for this potentially long running operation
* @return the host file given the parent path and file name.
* Must not return <code>null</code>, non-existing files should be
* reported with an IHostFile object where {@link IHostFile#exists()}
* returns <code>false</code>.
* @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the RemoteFileException family.
* @return the host file given the parent path and file name. Must not
* return <code>null</code>, non-existing files should be
* reported with an IHostFile object where
* {@link IHostFile#exists()} returns <code>false</code>.
* @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family.
*/
public IHostFile getFile(String remoteParent, String name, IProgressMonitor monitor) throws SystemMessageException;
/**
* List the contents of a remote folder.
*
* @param remoteParent - the name of the parent directory on the remote file
* system from which to retrieve the child list.
* @param fileFilter - a string that can be used to filter the children. Only
* those files matching the filter make it into the list. The interface
* does not dictate where the filtering occurs.
* @param fileType - indicates whether to query files, folders, both or some other type
* system from which to retrieve the child list.
* @param fileFilter - a string that can be used to filter the children.
* Only those files matching the filter make it into the list.
* The interface does not dictate where the filtering occurs.
* @param fileType - indicates whether to query files, folders, both or some
* other type
* @param monitor the monitor for this potentially long running operation
* @return the list of host files.
* @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the RemoteFileException family.
* @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family.
*
* @since org.eclipse.rse.services 3.0
*/
public IHostFile[] list(String remoteParent, String fileFilter, int fileType, IProgressMonitor monitor) throws SystemMessageException;
/**
* Get multiple abstract remote file handles for an array of specified
* paths.
*
* @param remoteParents - the list of remote parents
* @param names - the list of file names
* @param monitor the monitor for this potentially long running operation
* @return the host files given the parent paths and file names. This is basically a batch version of getFile().
* Must not return <code>null</code>, non-existing files should be
* reported with an IHostFile object where {@link IHostFile#exists()}
* returns <code>false</code>.
* @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the RemoteFileException family.
* @return the host files given the parent paths and file names. This is
* basically a batch version of getFile(). Must not return
* <code>null</code>, non-existing files should be reported with
* an IHostFile object where {@link IHostFile#exists()} returns
* <code>false</code>.
* @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family.
*
* @since org.eclipse.rse.services 3.0
*/
public IHostFile[] getFileMultiple(String remoteParents[], String names[], IProgressMonitor monitor) throws SystemMessageException;
/**
* @param remoteParents - the names of the parent directories on the remote file
* system from which to retrieve the collective child list.
* @param fileFilters - a set of strings that can be used to filter the children. Only
* those files matching the filter corresponding to it's remoteParent make it into the list. The interface
* does not dictate where the filtering occurs. For each remoteParent, there must be a corresponding
* fileFilter.
* @param fileTypes - indicates whether to query files, folders, both or some other type. For
* each remoteParent, there must be a corresponding fileType.
* For the default list of available file types see <code>IFileServiceContants</code>
* List the contents of multiple remote folders.
*
* @param remoteParents - the names of the parent directories on the remote
* file system from which to retrieve the collective child list.
* @param fileFilters - a set of strings that can be used to filter the
* children. Only those files matching the filter corresponding
* to it's remoteParent make it into the list. The interface does
* not dictate where the filtering occurs. For each remoteParent,
* there must be a corresponding fileFilter.
* @param fileTypes - indicates whether to query files, folders, both or
* some other type. For each remoteParent, there must be a
* corresponding fileType. For the default list of available file
* types see <code>IFileServiceContants</code>
* @param monitor the monitor for this potentially long running operation
* @return the collective list of host files that reside in each of the remoteParents with it's corresponding filter.
* @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the RemoteFileException family.
* @return the collective list of host files that reside in each of the
* remoteParents with it's corresponding filter.
* @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family.
*
* @since org.eclipse.rse.services 3.0
*/
public IHostFile[] listMultiple(String[] remoteParents, String[] fileFilters, int[] fileTypes, IProgressMonitor monitor) throws SystemMessageException;
/**
* @param remoteParents - the names of the parent directories on the remote file
* system from which to retrieve the collective child list.
* @param fileFilters - a set of strings that can be used to filter the children. Only
* those files matching the filter corresponding to it's remoteParent make it into the list. The interface
* does not dictate where the filtering occurs. For each remoteParent, there must be a corresponding
* fileFilter.
* @param fileType - indicates whether to query files, folders, both or some other type. For
* each remoteParent, there must be a corresponding fileType.
* For the default list of available file types see <code>IFileServiceContants</code>
* List the contents of multiple remote folders.
*
* @param remoteParents - the names of the parent directories on the remote
* file system from which to retrieve the collective child list.
* @param fileFilters - a set of strings that can be used to filter the
* children. Only those files matching the filter corresponding
* to it's remoteParent make it into the list. The interface does
* not dictate where the filtering occurs. For each remoteParent,
* there must be a corresponding fileFilter.
* @param fileType - indicates whether to query files, folders, both or some
* other type. All results will be of the specified type. For the
* default list of available file types see
* <code>IFileServiceContants</code>
* @param monitor the monitor for this potentially long running operation
* @return the collective list of host files that reside in each of the remoteParents with it's corresponding filter.
* @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the RemoteFileException family.
* @return the collective list of host files that reside in each of the
* remoteParents with it's corresponding filter.
* @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family.
*
* @since org.eclipse.rse.services 3.0
*/
public IHostFile[] listMultiple(String[] remoteParents, String[] fileFilters, int fileType, IProgressMonitor monitor) throws SystemMessageException;
/**
* Get abstract remote file handles for the known remote file system roots.
*
* @param monitor the monitor for this potentially long running operation
* Return the list of roots for this system
* Return the list of roots for this system
* @return the list of host files.
* @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the RemoteFileException family.
* @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family.
*/
public IHostFile[] getRoots(IProgressMonitor monitor) throws SystemMessageException;
@ -317,122 +360,138 @@ public interface IFileService extends IService
public IHostFile getUserHome();
/**
* Create a file on the host
* Create a file on the host.
*
* @param remoteParent the parent directory
* @param fileName the name of the new file
* @param monitor the monitor for this potentially long running operation
* @return the newly created file
* @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the RemoteFileException family.
* @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family.
*/
public IHostFile createFile(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException;
/**
* Create a folder on the host
* Create a folder on the host.
*
* @param remoteParent the parent directory
* @param folderName the name of the new folder
* @param monitor the progress monitor
* @return the newly created folder
* @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the RemoteFileException family.
* @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family.
*/
public IHostFile createFolder(String remoteParent, String folderName, IProgressMonitor monitor) throws SystemMessageException;
/**
* Deletes a file or folder on the host
* Delete a file or folder on the host.
*
* @param remoteParent the folder containing the file to delete
* @param fileName the name of the file or folder to delete
* @param monitor the progress monitor
* @return true if successful
* @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the RemoteFileException family.
* @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family.
*/
public boolean delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException;
/**
* Deletes a set of files or folders on the host. Should throw an exception if some files and folders were deleted and others were not
* due to an exception during the operation. Without an exception thrown in such cases, views may not be refreshed correctly to account
* for deleted resources.
* Delete a set of files or folders on the host. Should throw an exception
* if some files and folders were deleted and others were not due to an
* exception during the operation. Without an exception thrown in such
* cases, views may not be refreshed correctly to account for deleted
* resources.
*
* @param remoteParents the array of folders containing the files to delete
* @param fileNames the names of the files or folders to delete
* @param monitor the progress monitor
* @return true iff all deletes are successful
* @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the RemoteFileException family.
* @return <code>true</code> if all delete operations are successful,
* <code>false</code> otherwise.
* @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family.
*/
public boolean deleteBatch(String[] remoteParents, String[] fileNames, IProgressMonitor monitor) throws SystemMessageException;
/**
* Renames a file or folder on the host
* Rename a file or folder on the host.
*
* @param remoteParent the folder containing the file to rename
* @param oldName the old name of the file or folder to rename
* @param newName the new name for the file
* @param monitor the progress monitor
* @return true if successful
* @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the RemoteFileException family.
* @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family.
*/
public boolean rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException;
/**
* Renames a file or folder on the host
* Rename a file or folder on the host.
*
* @param remoteParent the folder containing the file to rename
* @param oldName the old name of the file or folder to rename
* @param newName the new name for the file
* @param oldFile the file to update with the change
* @param monitor the progress monitor
* @return true if successful
* @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the RemoteFileException family.
* @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family.
*/
public boolean rename(String remoteParent, String oldName, String newName, IHostFile oldFile, IProgressMonitor monitor) throws SystemMessageException;
/**
* Move the file or folder specified
* Move the file or folder specified to a different remote path.
*
* @param srcParent the folder containing the file or folder to move
* @param srcName the new of the file or folder to move
* @param tgtParent the destination folder for the move
* @param tgtName the name of the moved file or folder
* @param monitor the progress monitor
* @return true if the file was moved
* @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the RemoteFileException family.
* @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family.
*/
public boolean move(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException;
/**
* Copy the file or folder to the specified destination
* Copy the file or folder to the specified destination.
*
* @param srcParent the folder containing the file or folder to copy
* @param srcName the new of the file or folder to copy
* @param tgtParent the destination folder for the copy
* @param tgtName the name of the copied file or folder
* @param monitor the progress monitor
* @return true if the file was copied successfully
* @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the RemoteFileException family.
* @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family.
*/
public boolean copy(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException;
/**
* Copy a set of files or folders to the specified destination
* Copy a set of files or folders to the specified destination.
*
* @param srcParents the folders containing each file or folder to copy
* @param srcNames the names of the files or folders to copy
* @param tgtParent the destination folder for the copy
* @param monitor the progress monitor
* @return true if all files were copied
* @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the RemoteFileException family.
* @return <code>true</code> if all files were copied, <code>false</code>
* or exception otherwise.
* @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family.
*/
public boolean copyBatch(String[] srcParents, String[] srcNames, String tgtParent, IProgressMonitor monitor) throws SystemMessageException;
/**
* Indicates whether the file system is case sensitive
* Indicates whether the file system is case sensitive.
*
* @return true if the file system has case sensitive file names
*/
public boolean isCaseSensitive();
/**
* Sets the last modified stamp of the file or folder with the specified timestamp
* Set the last modified stamp of the file or folder with the specified
* timestamp.
*
* @param parent the parent path of the file to set
* @param name the name of the file to set
* @param timestamp the new timestamp
@ -442,12 +501,15 @@ public interface IFileService extends IService
public boolean setLastModified(String parent, String name, long timestamp, IProgressMonitor monitor) throws SystemMessageException;
/**
* Sets the readonly permission of the file or folder
* Set the read-only permission of the specified file or folder.
*
* @param parent the parent path of the file to set
* @param name the name of the file to set
* @param readOnly indicates whether to make the file readonly or read-write
* @param readOnly indicates whether to make the file read-only or
* read-write
* @param monitor the progress monitor
* @return true if the readonly permission was changed successfully, or the permission already was as desired
* @return true if the read-only permission was changed successfully, or the
* permission already was as desired
*/
public boolean setReadOnly(String parent, String name, boolean readOnly, IProgressMonitor monitor) throws SystemMessageException;
@ -461,39 +523,51 @@ public interface IFileService extends IService
public String getEncoding(IProgressMonitor monitor) throws SystemMessageException;
/**
* Gets the input stream to access the contents a remote file. Clients should close the input stream when done.
* Get the input stream to access the contents a remote file. Clients should
* close the input stream when done.
*
* @param remoteParent the absolute path of the parent.
* @param remoteFile the name of the remote file.
* @param isBinary <code>true</code> if the file is a binary file, <code>false</code> otherwise.
* @param isBinary <code>true</code> if the file is a binary file,
* <code>false</code> otherwise.
* @param monitor the progress monitor.
* @return the input stream to access the contents of the remote file.
* @throws SystemMessageException if an error occurs. S
* @since 2.0
* @throws SystemMessageException if an error occurs.
* @since org.eclipse.rse.services 2.0
*/
public InputStream getInputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException;
/**
* Gets the output stream to write to a remote file. Clients should close the output stream when done.
* Get the output stream to write to a remote file. Clients should close the
* output stream when done.
*
* @param remoteParent the absolute path of the parent.
* @param remoteFile the name of the remote file.
* @param isBinary <code>true</code> if the file is a binary file, <code>false</code> otherwise.
* @param isBinary <code>true</code> if the file is a binary file,
* <code>false</code> otherwise.
* @param monitor the progress monitor.
* @return the input stream to access the contents of the remote file.
* @throws SystemMessageException if an error occurs.
* @since 2.0
* @deprecated Use {@link #getOutputStream(String, String, int, IProgressMonitor)} instead
* @since org.eclipse.rse.services 2.0
* @deprecated Use
* {@link #getOutputStream(String, String, int, IProgressMonitor)}
* instead
*/
public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException;
/**
* Gets the output stream to write/append to a remote file. Clients should close the output stream when done.
* Get the output stream to write/append to a remote file. Clients should
* close the output stream when done.
*
* @param remoteParent the absolute path of the parent.
* @param remoteFile the name of the remote file.
* @param options bit wise or of option constants. Valid constants are {@link IFileService#APPEND}, {@link IFileService#TEXT_MODE}, and {@link IFileService#NONE}
* @param options bit wise or of option constants. Valid constants are
* {@link IFileService#APPEND}, {@link IFileService#TEXT_MODE},
* and {@link IFileService#NONE}
* @param monitor the progress monitor.
* @return the input stream to access the contents of the remote file.
* @throws SystemMessageException if an error occurs.
* @since 3.0
* @since org.eclipse.rse.services 3.0
*/
public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException;
@ -504,6 +578,8 @@ public interface IFileService extends IService
* display or enable themselves based on result of this call.
*
* @return whether this service supports encoding conversion
*
* @since org.eclipse.rse.services 3.0
*/
public boolean supportsEncodingConversion();
}

View file

@ -11,7 +11,7 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* {Name} (company) - description of contribution.
* Martin Oberhuber (Wind River) - [cleanup] Add API "since" tags
********************************************************************************/
package org.eclipse.rse.services.search;
@ -30,6 +30,8 @@ public interface IHostSearchConstants {
/**
* Status indicating configuration has been canceled, 2.
*
* @since 3.0 this was renamed from CANCELLED in earlier versions
*/
public static final int CANCELED = 2;