Module org.hsqldb

Class FileUtil

java.lang.Object
org.hsqldb.lib.FileUtil
All Implemented Interfaces:
FileAccess

public class FileUtil extends Object implements FileAccess
A collection of file management methods.

Also provides the default FileAccess implementation

Since:
1.7.2
Author:
Campbell Burnet (campbell-burnet@users dot sourceforge.net), Fred Toussi (fredt@users dot sourceforge.net), Ocke Janssen oj@openoffice.org
  • Field Details

    • fsIsIgnoreCase

      public final boolean fsIsIgnoreCase
    • fsNormalizesPosixSeparator

      public final boolean fsNormalizesPosixSeparator
  • Method Details

    • getFileUtil

      public static FileUtil getFileUtil()
    • getFileAccess

      public static FileAccess getFileAccess(boolean isResource)
    • isStreamElement

      public boolean isStreamElement(String elementName)
      Specified by:
      isStreamElement in interface FileAccess
    • openInputStreamElement

      public InputStream openInputStreamElement(String streamName) throws IOException
      Specified by:
      openInputStreamElement in interface FileAccess
      Throws:
      IOException
    • createParentDirs

      public void createParentDirs(String filename)
      Specified by:
      createParentDirs in interface FileAccess
    • removeElement

      public boolean removeElement(String filename)
      Specified by:
      removeElement in interface FileAccess
    • renameElement

      public boolean renameElement(String oldName, String newName)
      Specified by:
      renameElement in interface FileAccess
    • renameElementOrCopy

      public boolean renameElementOrCopy(String oldName, String newName, EventLogInterface logger)
      Specified by:
      renameElementOrCopy in interface FileAccess
    • openOutputStreamElement

      public OutputStream openOutputStreamElement(String streamName) throws IOException
      Specified by:
      openOutputStreamElement in interface FileAccess
      Throws:
      IOException
    • openOutputStreamElementAppend

      public OutputStream openOutputStreamElementAppend(String streamName) throws IOException
      Specified by:
      openOutputStreamElementAppend in interface FileAccess
      Throws:
      IOException
    • delete

      public boolean delete(String filename)
      Delete the named file
      Parameters:
      filename - String
      Returns:
      true if deleted
    • deleteOnExit

      public void deleteOnExit(File f)
      Requests, in a JDK 1.1 compliant way, that the file or directory denoted by the given abstract pathname be deleted when the virtual machine terminates.

      Deletion will be attempted only for JDK 1.2 and greater runtime environments and only upon normal termination of the virtual machine, as defined by the Java Language Specification.

      Once deletion has been sucessfully requested, it is not possible to cancel the request. This method should therefore be used with care.

      Parameters:
      f - the abstract pathname of the file be deleted when the virtual machine terminates
    • exists

      public boolean exists(String filename)
      Return true or false based on whether the named file exists.
      Parameters:
      filename - String
      Returns:
      true if exists
    • exists

      public boolean exists(String fileName, boolean resource, Class cla)
    • absolutePath

      public String absolutePath(String path)
      Retrieves the absolute path, given some path specification.
      Parameters:
      path - the path for which to retrieve the absolute path
      Returns:
      the absolute path
    • canonicalFile

      public File canonicalFile(File f) throws IOException
      Retrieves the canonical file for the given file, in a JDK 1.1 compliant way.
      Parameters:
      f - the File for which to retrieve the absolute File
      Returns:
      the canonical File
      Throws:
      IOException - on error
    • canonicalFile

      public File canonicalFile(String path) throws IOException
      Retrieves the canonical file for the given path, in a JDK 1.1 compliant way.
      Parameters:
      path - the path for which to retrieve the canonical File
      Returns:
      the canonical File
      Throws:
      IOException - on error
    • canonicalPath

      public String canonicalPath(File f) throws IOException
      Retrieves the canonical path for the given File, in a JDK 1.1 compliant way.
      Parameters:
      f - the File for which to retrieve the canonical path
      Returns:
      the canonical path
      Throws:
      IOException - on error
    • canonicalPath

      public String canonicalPath(String path) throws IOException
      Retrieves the canonical path for the given path, in a JDK 1.1 compliant way.
      Parameters:
      path - the path for which to retrieve the canonical path
      Returns:
      the canonical path
      Throws:
      IOException - on error
    • canonicalOrAbsolutePath

      public String canonicalOrAbsolutePath(String path)
      Retrieves the canonical path for the given path, or the absolute path if attempting to retrieve the canonical path fails.
      Parameters:
      path - the path for which to retrieve the canonical or absolute path
      Returns:
      the canonical or absolute path
    • makeParentDirectories

      public void makeParentDirectories(File f)
    • makeDirectories

      public static String makeDirectories(String path)
    • getFileSync

      public FileAccess.FileSync getFileSync(OutputStream os) throws IOException
      Specified by:
      getFileSync in interface FileAccess
      Throws:
      IOException
    • deleteOrRenameDatabaseFiles

      public static boolean deleteOrRenameDatabaseFiles(String dbNamePath)
      Utility method for user applications. Attempts to delete all the files for the database as listed by the getDatabaseFileList() method. If any of the current, main database files cannot be deleted, it is renamed by adding a suffix containing a hexadecimal timestamp portion and the ".old" extension. Also deletes the ".tmp" directory.
      Parameters:
      dbNamePath - full path or name of database (without a file extension)
      Returns:
      currently always true
    • getDatabaseFileList

      public static File[] getDatabaseFileList(String dbNamePath)
      Utility method for user applications. Returns a list of files that currently exist for a database. The list includes current database files as well as ".new", and ".old" versions of the files, plus any app logs.
      Parameters:
      dbNamePath - full path or name of database (without a file extension)
      Returns:
      File[]
    • getDatabaseMainFileList

      public static File[] getDatabaseMainFileList(String dbNamePath)
      Returns a list of existing main files for a database. The list excludes non-essential files.
      Parameters:
      dbNamePath - full path or name of database (without a file extension)
      Returns:
      File[]
    • newDiscardFileName

      public static String newDiscardFileName(String filename)