org.eclipse.core.internal.utils
Class FileUtil

java.lang.Object
  extended by org.eclipse.core.internal.utils.FileUtil

public class FileUtil
extends java.lang.Object

Static utility methods for manipulating Files and URIs.


Method Summary
static org.eclipse.core.filesystem.IFileInfo attributesToFileInfo(ResourceAttributes attributes)
          Converts a ResourceAttributes object into an IFileInfo object.
static org.eclipse.core.runtime.IPath canonicalPath(org.eclipse.core.runtime.IPath path)
          Converts an IPath into its canonical form for the local file system.
static java.net.URI canonicalURI(java.net.URI uri)
          Converts a URI into its canonical form.
static ResourceAttributes fileInfoToAttributes(org.eclipse.core.filesystem.IFileInfo fileInfo)
          Converts an IFileInfo object into a ResourceAttributes object.
static boolean isOverlapping(java.net.URI location1, java.net.URI location2)
          Returns true if the given file system locations overlap, and false otherwise.
static boolean isPrefixOf(org.eclipse.core.runtime.IPath location1, org.eclipse.core.runtime.IPath location2)
          Returns true if location1 is the same as, or a proper prefix of, location2.
static boolean isPrefixOf(java.net.URI location1, java.net.URI location2)
          Returns true if location1 is the same as, or a proper prefix of, location2.
static void safeClose(java.io.InputStream in)
          Closes a stream and ignores any resulting exception.
static void safeClose(java.io.OutputStream out)
          Closes a stream and ignores any resulting exception.
static org.eclipse.core.runtime.IPath toPath(java.net.URI uri)
          Converts a URI to an IPath.
static void transferStreams(java.io.InputStream source, java.io.OutputStream destination, java.lang.String path, org.eclipse.core.runtime.IProgressMonitor monitor)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

attributesToFileInfo

public static org.eclipse.core.filesystem.IFileInfo attributesToFileInfo(ResourceAttributes attributes)
Converts a ResourceAttributes object into an IFileInfo object.

Parameters:
attributes - The resource attributes
Returns:
The file info

canonicalPath

public static org.eclipse.core.runtime.IPath canonicalPath(org.eclipse.core.runtime.IPath path)
Converts an IPath into its canonical form for the local file system.


canonicalURI

public static java.net.URI canonicalURI(java.net.URI uri)
Converts a URI into its canonical form.


fileInfoToAttributes

public static ResourceAttributes fileInfoToAttributes(org.eclipse.core.filesystem.IFileInfo fileInfo)
Converts an IFileInfo object into a ResourceAttributes object.

Parameters:
fileInfo - The file info
Returns:
The resource attributes

isOverlapping

public static boolean isOverlapping(java.net.URI location1,
                                    java.net.URI location2)
Returns true if the given file system locations overlap, and false otherwise. Overlap means the locations are the same, or one is a proper prefix of the other.


isPrefixOf

public static boolean isPrefixOf(org.eclipse.core.runtime.IPath location1,
                                 org.eclipse.core.runtime.IPath location2)
Returns true if location1 is the same as, or a proper prefix of, location2. Returns false otherwise.


isPrefixOf

public static boolean isPrefixOf(java.net.URI location1,
                                 java.net.URI location2)
Returns true if location1 is the same as, or a proper prefix of, location2. Returns false otherwise.


safeClose

public static void safeClose(java.io.InputStream in)
Closes a stream and ignores any resulting exception. This is useful when doing stream cleanup in a finally block where secondary exceptions are not worth logging.


safeClose

public static void safeClose(java.io.OutputStream out)
Closes a stream and ignores any resulting exception. This is useful when doing stream cleanup in a finally block where secondary exceptions are not worth logging.


toPath

public static org.eclipse.core.runtime.IPath toPath(java.net.URI uri)
Converts a URI to an IPath. Returns null if the URI cannot be represented as an IPath.

Note this method differs from URIUtil in its handling of relative URIs as being relative to path variables.


transferStreams

public static final void transferStreams(java.io.InputStream source,
                                         java.io.OutputStream destination,
                                         java.lang.String path,
                                         org.eclipse.core.runtime.IProgressMonitor monitor)
                                  throws org.eclipse.core.runtime.CoreException
Throws:
org.eclipse.core.runtime.CoreException