Package org.eclipse.osgi.storage
Class StorageUtil
java.lang.Object
org.eclipse.osgi.storage.StorageUtil
A utility class with some generally useful static methods for adaptor hook
implementations
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanstatic voidCopies the content of the given path (file or directory) to the specified target.static URLencodeFileURL(File file) static byte[]getBytes(InputStream in, int length, int BUF_SIZE) static booleanisReservedFileName(File file) Tests whether the filename can escape path into special devicestatic voidstatic voidreadFile(InputStream in, File file) Read a file from an InputStream and write it to the file system.static ServiceRegistration<?> register(String name, Object service, BundleContext context) Register a service object.static booleanThis function performs the equivalent of "rm -r" on a file or directory.
-
Constructor Details
-
StorageUtil
public StorageUtil()
-
-
Method Details
-
copy
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
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
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
Register a service object.- Parameters:
name- the service class nameservice- the service objectcontext- the registering bundle context- Returns:
- the service registration object
-
canWrite
-
encodeFileURL
- Throws:
MalformedURLException
-
getBytes
- Throws:
IOException
-
move
public static void move(File from, File to, org.eclipse.osgi.internal.debug.Debug debug) throws IOException - Throws:
IOException
-
isReservedFileName
Tests whether the filename can escape path into special device
-