Class StorageUtil

java.lang.Object
org.eclipse.osgi.storage.StorageUtil

public class StorageUtil extends Object
A utility class with some generally useful static methods for adaptor hook implementations
  • Constructor Details

    • StorageUtil

      public StorageUtil()
  • Method Details

    • copy

      public static void copy(File inFile, File outFile) throws IOException
      Copies the content of the given path (file or directory) to the specified target. If the source is a directory all contained elements are copied recursively.
      Parameters:
      inFile - input directory to copy.
      outFile - output directory to copy to.
      Throws:
      IOException - if any error occurs during the copy.
    • readFile

      public static void readFile(InputStream in, File file) throws IOException
      Read a file from an InputStream and write it to the file system.
      Parameters:
      in - InputStream from which to read. This stream will be closed by this method.
      file - output file to create.
      Throws:
      IOException
    • rm

      public static boolean rm(File file, boolean DEBUG)
      This function performs the equivalent of "rm -r" on a file or directory.
      Parameters:
      file - file or directory to delete
      Returns:
      false is the specified files still exists, true otherwise.
    • register

      public static ServiceRegistration<?> register(String name, Object service, BundleContext context)
      Register a service object.
      Parameters:
      name - the service class name
      service - the service object
      context - the registering bundle context
      Returns:
      the service registration object
    • canWrite

      public static boolean canWrite(File installDir)
    • encodeFileURL

      public static URL encodeFileURL(File file) throws MalformedURLException
      Throws:
      MalformedURLException
    • getBytes

      public static byte[] getBytes(InputStream in, int length, int BUF_SIZE) throws IOException
      Throws:
      IOException
    • move

      public static void move(File from, File to, boolean DEBUG) throws IOException
      Throws:
      IOException
    • isReservedFileName

      public static boolean isReservedFileName(File file)
      Tests whether the filename can escape path into special device