org.apache.derby.iapi.services.io
Class FileUtil

java.lang.Object
  extended by org.apache.derby.iapi.services.io.FileUtil

public abstract class FileUtil
extends java.lang.Object

A set of public static methods for dealing with File objects.


Field Summary
private static java.lang.Class aclEntryBuilderClz
           
private static java.lang.Class aclEntryClz
           
private static java.lang.Class aclEntryPermissionClz
           
private static java.lang.Class aclEntryTypeClz
           
private static java.lang.Class aclFileAttributeViewClz
           
private static java.lang.reflect.Field allow
           
private static int BUFFER_SIZE
           
private static java.lang.reflect.Method build
           
private static java.lang.Class fileClz
           
private static java.lang.Class filesClz
           
private static java.lang.Class fileStoreClz
           
private static java.lang.reflect.Method get
           
private static java.lang.reflect.Method getAcl
           
private static java.lang.reflect.Method getFileAttributeView
           
private static java.lang.reflect.Method getFileStore
           
private static java.lang.reflect.Method getName
           
private static java.lang.reflect.Method getOwner
           
private static boolean initialized
           
private static java.lang.Class linkOptionArrayClz
           
private static java.lang.Class linkOptionClz
           
private static java.lang.reflect.Method newBuilder
           
private static java.lang.Class pathClz
           
private static java.lang.Class pathsClz
           
private static java.lang.Class posixFileAttributeViewClz
           
private static java.lang.reflect.Method principal
           
private static java.lang.Object region
           
private static java.lang.reflect.Method setAcl
           
private static java.lang.reflect.Method setExec
           
private static java.lang.reflect.Method setPermissions
           
private static java.lang.reflect.Method setPrincipal
           
private static java.lang.reflect.Method setRead
           
private static java.lang.reflect.Method setType
           
private static java.lang.reflect.Method setWrite
           
private static java.lang.Class stringArrayClz
           
private static java.lang.reflect.Method supportsFileAttributeView
           
private static java.lang.Class userPrincipalClz
           
private static java.lang.reflect.Method values
           
 
Constructor Summary
FileUtil()
           
 
Method Summary
private static void assertTrue(java.lang.Object r)
           
static boolean copyDirectory(java.io.File from, java.io.File to)
          Copy a directory and all of its contents.
static boolean copyDirectory(java.io.File from, java.io.File to, byte[] buffer, java.lang.String[] filter)
           
static boolean copyDirectory(StorageFactory storageFactory, StorageFile from, java.io.File to, byte[] buffer, java.lang.String[] filter, boolean copySubDirs)
           
static boolean copyDirectory(java.lang.String from, java.lang.String to)
           
static boolean copyDirectory(WritableStorageFactory storageFactory, java.io.File from, StorageFile to)
           
static boolean copyDirectory(WritableStorageFactory storageFactory, java.io.File from, StorageFile to, byte[] buffer, java.lang.String[] filter)
           
static boolean copyFile(java.io.File from, java.io.File to, byte[] buf)
           
static boolean copyFile(StorageFactory storageFactory, StorageFile from, java.io.File to)
           
static boolean copyFile(StorageFactory storageFactory, StorageFile from, java.io.File to, byte[] buf)
           
static boolean copyFile(WritableStorageFactory storageFactory, java.io.File from, StorageFile to)
           
static boolean copyFile(WritableStorageFactory storageFactory, java.io.File from, StorageFile to, byte[] buf)
           
static boolean copyFile(WritableStorageFactory storageFactory, StorageFile from, StorageFile to)
           
static boolean copyFile(WritableStorageFactory storageFactory, StorageFile from, StorageFile to, byte[] buf)
           
static java.io.File getAbsoluteFile(java.io.File root, java.lang.String path)
          Convert a file path into a File object with an absolute path relative to a passed in root.
static void limitAccessToOwner(java.io.File file)
          Use when creating new files.
private static boolean limitAccessToOwnerViaACLs(java.io.File file)
           
static java.io.File newFile(java.io.File parent, java.lang.String name)
          A replacement for new File(File, String) that correctly implements the case when the first argument is null.
static boolean removeDirectory(java.io.File directory)
          Remove a directory and all of its contents.
static boolean removeDirectory(java.lang.String directory)
           
static java.lang.String stripProtocolFromFileName(java.lang.String originalName)
          Remove the leading 'file://' protocol from a filename which has been expressed as an URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER_SIZE

private static final int BUFFER_SIZE
See Also:
Constant Field Values

region

private static final java.lang.Object region

initialized

private static boolean initialized

setWrite

private static java.lang.reflect.Method setWrite

setRead

private static java.lang.reflect.Method setRead

setExec

private static java.lang.reflect.Method setExec

fileClz

private static java.lang.Class fileClz

filesClz

private static java.lang.Class filesClz

pathClz

private static java.lang.Class pathClz

pathsClz

private static java.lang.Class pathsClz

aclEntryClz

private static java.lang.Class aclEntryClz

aclFileAttributeViewClz

private static java.lang.Class aclFileAttributeViewClz

posixFileAttributeViewClz

private static java.lang.Class posixFileAttributeViewClz

userPrincipalClz

private static java.lang.Class userPrincipalClz

linkOptionArrayClz

private static java.lang.Class linkOptionArrayClz

linkOptionClz

private static java.lang.Class linkOptionClz

stringArrayClz

private static java.lang.Class stringArrayClz

aclEntryBuilderClz

private static java.lang.Class aclEntryBuilderClz

aclEntryTypeClz

private static java.lang.Class aclEntryTypeClz

fileStoreClz

private static java.lang.Class fileStoreClz

aclEntryPermissionClz

private static java.lang.Class aclEntryPermissionClz

get

private static java.lang.reflect.Method get

getFileAttributeView

private static java.lang.reflect.Method getFileAttributeView

supportsFileAttributeView

private static java.lang.reflect.Method supportsFileAttributeView

getFileStore

private static java.lang.reflect.Method getFileStore

getOwner

private static java.lang.reflect.Method getOwner

getAcl

private static java.lang.reflect.Method getAcl

setAcl

private static java.lang.reflect.Method setAcl

principal

private static java.lang.reflect.Method principal

getName

private static java.lang.reflect.Method getName

build

private static java.lang.reflect.Method build

newBuilder

private static java.lang.reflect.Method newBuilder

setPrincipal

private static java.lang.reflect.Method setPrincipal

setType

private static java.lang.reflect.Method setType

values

private static java.lang.reflect.Method values

setPermissions

private static java.lang.reflect.Method setPermissions

allow

private static java.lang.reflect.Field allow
Constructor Detail

FileUtil

public FileUtil()
Method Detail

removeDirectory

public static boolean removeDirectory(java.io.File directory)
Remove a directory and all of its contents. The results of executing File.delete() on a File object that represents a directory seems to be platform dependent. This method removes the directory and all of its contents.

Returns:
true if the complete directory was removed, false if it could not be. If false is returned then some of the files in the directory may have been removed.

removeDirectory

public static boolean removeDirectory(java.lang.String directory)

copyDirectory

public static boolean copyDirectory(java.io.File from,
                                    java.io.File to)
Copy a directory and all of its contents.


copyDirectory

public static boolean copyDirectory(java.lang.String from,
                                    java.lang.String to)

copyDirectory

public static boolean copyDirectory(java.io.File from,
                                    java.io.File to,
                                    byte[] buffer,
                                    java.lang.String[] filter)
Parameters:
filter - - array of names to not copy.

copyFile

public static boolean copyFile(java.io.File from,
                               java.io.File to,
                               byte[] buf)

copyDirectory

public static boolean copyDirectory(StorageFactory storageFactory,
                                    StorageFile from,
                                    java.io.File to,
                                    byte[] buffer,
                                    java.lang.String[] filter,
                                    boolean copySubDirs)

copyFile

public static boolean copyFile(StorageFactory storageFactory,
                               StorageFile from,
                               java.io.File to)

copyFile

public static boolean copyFile(StorageFactory storageFactory,
                               StorageFile from,
                               java.io.File to,
                               byte[] buf)

copyDirectory

public static boolean copyDirectory(WritableStorageFactory storageFactory,
                                    java.io.File from,
                                    StorageFile to)

copyDirectory

public static boolean copyDirectory(WritableStorageFactory storageFactory,
                                    java.io.File from,
                                    StorageFile to,
                                    byte[] buffer,
                                    java.lang.String[] filter)

copyFile

public static boolean copyFile(WritableStorageFactory storageFactory,
                               java.io.File from,
                               StorageFile to)

copyFile

public static boolean copyFile(WritableStorageFactory storageFactory,
                               java.io.File from,
                               StorageFile to,
                               byte[] buf)

copyFile

public static boolean copyFile(WritableStorageFactory storageFactory,
                               StorageFile from,
                               StorageFile to)

copyFile

public static boolean copyFile(WritableStorageFactory storageFactory,
                               StorageFile from,
                               StorageFile to,
                               byte[] buf)

getAbsoluteFile

public static java.io.File getAbsoluteFile(java.io.File root,
                                           java.lang.String path)
Convert a file path into a File object with an absolute path relative to a passed in root. If path is absolute then a file object constructed from new File(path) is returned, otherwise a file object is returned from new File(root, path) if root is not null, otherwise null is returned.


newFile

public static java.io.File newFile(java.io.File parent,
                                   java.lang.String name)
A replacement for new File(File, String) that correctly implements the case when the first argument is null. The documentation for java.io.File says that new File((File) null, name) is the same as new File(name). This is not the case in pre 1.1.8 vms, a NullPointerException is thrown instead.


stripProtocolFromFileName

public static java.lang.String stripProtocolFromFileName(java.lang.String originalName)
Remove the leading 'file://' protocol from a filename which has been expressed as an URL. If the filename is not an URL, then nothing is done. Otherwise, an URL like 'file:///tmp/foo.txt' is transformed into the legal file name '/tmp/foo.txt'.


limitAccessToOwner

public static void limitAccessToOwner(java.io.File file)
Use when creating new files. If running with Java 6 or higher on Unix, limit read and write permissions on file to owner if derby.storage.useDefaultFilePermissions == false.

If the property is not specified, we use restrictive permissions anyway iff running with the server server started from the command line.

On Unix, this is equivalent to running with umask 0077.

On Windows, with FAT/FAT32, we lose, since the fs does not support permissions, only a read-only flag.

On Windows, with NTFS with ACLs, if running with Java 7 or higher, we limit access also for Windows using the new java.nio.file.attribute package.

Parameters:
file - assumed to be just created

assertTrue

private static void assertTrue(java.lang.Object r)

limitAccessToOwnerViaACLs

private static boolean limitAccessToOwnerViaACLs(java.io.File file)

Built on Wed 2013-06-12 15:21:56+0000, from revision ???

Apache Derby V10.10 Internals - Copyright © 2004,2013 The Apache Software Foundation. All Rights Reserved.