ewe.io
Class FileBase

java.lang.Object
  extended byewe.io.FileSys
      extended byewe.io.FileBase
All Implemented Interfaces:
FilePermissions, Streamable, Textable
Direct Known Subclasses:
File

public abstract class FileBase
extends FileSys
implements Textable, Streamable, FilePermissions

This class is used as base for the Java and abstract versions of File.


Field Summary
static int ClosedFolderIcon
           
static int CREATE
          Deprecated. READ_WRITE will create a file if one does not exist.
static int DriveIcon
           
static int FileIcon
           
static int FLAG_CASE_SENSITIVE
          This is a flag returned from getInfo(INFO_FLAGS);
static int FLAG_FILE_SYSTEM_IS_READ_ONLY
          This is a flag returned from getInfo(INFO_FLAGS);
static int FLAG_READ_ONLY
          Deprecated. - use getPermissionsAndFlags() and changePermissionsAndFlags()
static int FLAG_SLOW_ACCESS
          This is a flag returned from getInfo(INFO_FLAGS);
static int FLAG_SLOW_CHILD_COUNT
           
static int FLAG_SLOW_LIST
           
static int INFO_DETAIL_NAMES
          This should return an array of Strings giving the details to display about a file in the filechooser box.
static int INFO_DETAIL_WIDTHS
          This should return EITHER an array of ints giving the width of each detail column (except for name) or an array of Strings which represent the widest string expected for each column.
static int INFO_DETAILS
          This should return a String a particular detail for the file.
static int INFO_DEVICE_ICON
          This returns an IImage representing the device on which the file is stored.
static int INFO_DEVICE_NAME
          This returns a String which is the name of the computer.
static int INFO_FILE_TIMES
          This is used to get/set the three file times for a file - the creation date, the last modification date and the last access date, in that order.
static int INFO_FLAGS
          This gets a set of File or device specific flags.
static int INFO_FREE_DRIVE_SPACE
          This returns a Long specifying the number of free bytes on the disk, or null if it cannot be determined.
static int INFO_GROUP
          This is used to get/set the group of a file.
static int INFO_ICON
          This requests the icon for the file - returns an IImage object.
static int INFO_ICON_LARGE
           
static int INFO_ICON_MEDIUM
           
static int INFO_ICON_SMALL
           
static int INFO_LINK_DESTINATION
          NOT IMPLEMENTED YET.
static int INFO_OWNER
          This is used to get/set the owner of a file.
static int INFO_PROGRAM_DIRECTORY
          This returns a String which is the directory where the program is installed.
static int INFO_ROOT_LIST
          This requests the names of the root directory of all drives - returns an array of Strings.
static int INFO_SYSTEM_TYPE
          Used for getting the file system type.
static int INFO_TEMPORARY_DIRECTORY
          This returns a String which is the directory where temporary files can be created.
static int INFO_TOOL_TIP
          This should return a String representing a "tool-tip" to display for a file in the Filechooser box.
static int INFO_TOTAL_DRIVE_SPACE
          This returns a Long specifying the total number of bytes on the the disk, or null if it cannot be determined.
static int LIST_ALWAYS_INCLUDE_DIRECTORIES
          This option lists all directories even if they don't match the supplied mask.
static int LIST_BY_DATE
           
static int LIST_BY_SIZE
           
static int LIST_BY_TYPE
           
static int LIST_CHECK_FOR_ANY_MATCHING_CHILDREN
          This option request that only a check for matching children is done, rather than a listing.
static int LIST_DESCENDING
           
static int LIST_DIRECTORIES_LAST
           
static int LIST_DIRECTORIES_ONLY
           
static int LIST_DONT_SORT
           
static int LIST_FILES_ONLY
           
static int LIST_IGNORE_DIRECTORY_STATUS
          This option treats directories and files as being the same.
protected  String name
           
static int OpenFolderIcon
           
static int PageIcon
           
static String pathSeparator
           
static char pathSeparatorChar
           
static int READ_ONLY
          Read-only open mode.
static int READ_WRITE
          Read-write open mode.
static String separator
           
static char separatorChar
           
static int WRITE_ONLY
          Write-only open mode.
 
Fields inherited from class ewe.io.FileSys
DOS_SYSTEM, MEMORY_SYSTEM, PALM_SYSTEM, UNIX_SYSTEM
 
Fields inherited from interface ewe.io.FilePermissions
ALL_DOS_FLAGS, ALL_UNIX_PERMISSIONS, FLAG_ARCHIVE, FLAG_HIDDEN, FLAG_READONLY, FLAG_ROM, FLAG_ROMMODULE, FLAG_SYSTEM, GROUP_EXECUTE, GROUP_READ, GROUP_WRITE, OTHER_EXECUTE, OTHER_READ, OTHER_WRITE, OWNER_EXECUTE, OWNER_READ, OWNER_WRITE
 
Constructor Summary
protected FileBase()
           
 
Method Summary
 boolean canRead()
          Returns true if the file exists and can be read.
 boolean canWrite()
           
 boolean changePermissionsAndFlags(int valuesToSet, int valuesToClear)
          Change ther permissions/flags for this File - see ewe.io.FilePermissions for a list of the available flag permissions.
static int convertMode(String mode)
          A utility method to convert from "r" or "rw" to READ_ONLY or READ_WRITE mode.
abstract  boolean createDir()
          Creates a directory.
 File createTempFile(String fileName, File dir)
          This creates an empty file with a specific name in a temporary directory.
 File createTempFile(String prefix, String suffix, File dir)
          This creates an empty temporary file with the specified prefix and suffix.
abstract  boolean delete()
          Deletes the file or directory.
abstract  void deleteOnExit()
          This tells the system to delete the file when the program exits.
 boolean equals(Object other)
          This checks to see if the two files refer to the same object in the file system.
abstract  boolean exists()
          Returns true if the file exists and false otherwise.
 boolean filePathsAreEqual(String one, String two)
           
static String fixupPath(String path)
           
 File getAbsoluteFile()
           
 String getAbsolutePath()
          This differs from getFullPath() in that this will convert all '\' characters to '/' characters.
 File getCanonicalFile()
           
 String getCanonicalPath()
           
 File getChild(String path)
           
 String getCreationName()
          Return the file's path, as specified when created.
 String getDrivePath()
          Return only the drive and path of the file.
static String getDrivePath(String str)
           
 String getFileExt()
          Return only the filename and extension of the file.
static String getFileExt(String str)
           
 int getFlags()
          A quick way to get the flags from getInfo().
abstract  String getFullPath()
          Return the fully qualified pathname of the file.
static IImage getIcon(int whichIcon)
          Get one of the icons: OpenFolderIcon, ClosedFolderIcon and PageIcon.
 Object getInfo(int infoCode)
           
abstract  Object getInfo(int infoCode, Object sourceParameters, Object resultDestination, int options)
          This method is used to get extended information about the File or the File system in general.
 Stream getInputStream()
          Deprecated. use toReadableStream() instead.
abstract  int getLength()
           
 Time getModified(Time dest)
          Return the Time the File was last modified.
 String getName()
          Get the name associated with this Streamable object.
 File getNew(File directory, String path)
          Get a new File object given the directory and new path.
 File getNew(String path)
          Get a new File object given the directory and new path.
static File getNewFile()
          Get a new File object for the default file system used by the VM.
static File getNewFile(File directory, String name)
          Get a new File object for the default file system used by the VM.
static File getNewFile(String name)
          Get a new File object for the default file system used by the VM.
protected abstract  File getNewInstance()
           
 Stream getOutputStream()
          Deprecated. use toWritableStream() instead.
 String getParent()
           
 File getParentFile()
          Get a File object representing the parent direcotry of this File.
 String getPath()
           
 int getPermissionsAndFlags(int interestedFlags)
          Get ther permissions/flags for this File - see ewe.io.FilePermissions for a list of the available flag permissions.
static String getProgramDirectory()
          A quick way to get the program directory for the application.
 String getPropertiesString()
           
 RandomAccessStream getRandomAccessStream(int mode)
          Deprecated. use toRandomAccessStream() instead.
protected abstract  void getSetModified(Time time, boolean doGet)
          This gets/sets the modified time of the file.
protected  int getSetPermissionsAndFlags(boolean isGet, int valuesToSetOrGet, int valuesToClear)
          This is used to implement getPermissionsAndFlags() and changePermissionsAndFlags().
 String getText()
           
static String getTrueChild(File parent, String child, File aFile)
           
static File getTrueParent(File parent, String child, File aFile)
           
 int hashCode()
          Returns a hashCode for the object.
abstract  boolean isDirectory()
          Returns true if the file is a directory and false otherwise.
 boolean isFile()
           
 boolean isHidden()
           
 boolean isSameFileSystem(File other)
          Returns true if the other file system is considered the same as this one.
 boolean isSameVolume(File other)
          Checks if the volume which contains the other File is considered the same as the one that contains this File.
 long lastModified()
           
 String[] list()
          Lists all files on the directory that this File object represents, sorted by name - with directories listed first.
 String[] list(FilenameFilter filter)
          List all files in this directory using the specified filter.
 String[] list(String mask, int listAndSortOptions)
          Lists the files contained in a directory.
abstract  Handle listFiles(String mask, int listAndSortOptions)
          List files asynchronously.
 String[] listMultiple(String compositeMask, int listAndSortOptions)
          Lists the files contained in a directory using a complex mask - which may actually consist of multiple masks (e.g.
static File[] listRoots()
          List all the root files in the default file system.
static String makePath(File parent, String child)
          Utility to create a path name given a parent and child.
static String makePath(String parent, String child)
          Utility to create a path name given a parent and child.
 boolean mkdir()
           
 boolean mkdirs()
          Create a directory and all necessary parent directories.
abstract  boolean move(File newFile)
          This moves/renames the file to the destination new File.
 Handle refresh()
          This tells the File system to consider any cached directory invalid so so that a list() call will do a true lookup.
static String removeTrailingSlash(String path)
           
 boolean rename(String newName)
          This renames the file in place.
 boolean renameTo(File newFile)
           
abstract  void set(File directory, String path)
          Modifies the File to point to a different file on the file system.
 Handle setInfo(int infoCode, Object sourceParameters, int options)
          This is used to set extended information about the File or the File system in general.
 boolean setInfo(int infoCode, Object sourceParameters, Object resultDesination, int options)
          Deprecated. use the other setInfo() instead.
 boolean setLastModified(long time)
           
 void setModified(Time modifiedTime)
          Set the last modified time for the file.
 void setText(String text)
           
 RandomAccessStream toRandomAccessStream(String mode)
          Create and return a RandomAccessStream for reading/writing to the data associated with this File object.
 Stream toReadableStream()
          Create and return a Stream to use for reading from the File.
 Handle toStream(boolean isRandom, String type)
          Requests the possibly asynchronous creation of a Stream object for reading or writing.
 String toString()
          Return a String representation of this object.
static String toSystemDependantPath(String path)
          This converts any '/' directory separators to the one that is native to the running OS (ie '\' on Windows) and any ';' path separtors to the one that is native to the running OS (ie ':' on Unix/Linux).
 Stream toWritableStream(boolean append)
          Create and return a Stream to use for writing to the File.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass
 

Field Detail

name

protected String name

OpenFolderIcon

public static final int OpenFolderIcon
See Also:
Constant Field Values

ClosedFolderIcon

public static final int ClosedFolderIcon
See Also:
Constant Field Values

PageIcon

public static final int PageIcon
See Also:
Constant Field Values

FileIcon

public static final int FileIcon
See Also:
Constant Field Values

DriveIcon

public static final int DriveIcon
See Also:
Constant Field Values

READ_ONLY

public static final int READ_ONLY
Read-only open mode.

See Also:
Constant Field Values

WRITE_ONLY

public static final int WRITE_ONLY
Write-only open mode.

See Also:
Constant Field Values

READ_WRITE

public static final int READ_WRITE
Read-write open mode.

See Also:
Constant Field Values

CREATE

public static final int CREATE
Deprecated. READ_WRITE will create a file if one does not exist.

Create open mode. Used to create a file if one does not exist.

See Also:
Constant Field Values

LIST_DESCENDING

public static final int LIST_DESCENDING
See Also:
Constant Field Values

LIST_DIRECTORIES_LAST

public static final int LIST_DIRECTORIES_LAST
See Also:
Constant Field Values

LIST_DIRECTORIES_ONLY

public static final int LIST_DIRECTORIES_ONLY
See Also:
Constant Field Values

LIST_FILES_ONLY

public static final int LIST_FILES_ONLY
See Also:
Constant Field Values

LIST_BY_DATE

public static final int LIST_BY_DATE
See Also:
Constant Field Values

LIST_BY_TYPE

public static final int LIST_BY_TYPE
See Also:
Constant Field Values

LIST_DONT_SORT

public static final int LIST_DONT_SORT
See Also:
Constant Field Values

LIST_IGNORE_DIRECTORY_STATUS

public static final int LIST_IGNORE_DIRECTORY_STATUS
This option treats directories and files as being the same.

See Also:
Constant Field Values

LIST_ALWAYS_INCLUDE_DIRECTORIES

public static final int LIST_ALWAYS_INCLUDE_DIRECTORIES
This option lists all directories even if they don't match the supplied mask.

See Also:
Constant Field Values

LIST_CHECK_FOR_ANY_MATCHING_CHILDREN

public static final int LIST_CHECK_FOR_ANY_MATCHING_CHILDREN
This option request that only a check for matching children is done, rather than a listing. It will cause list() to behave as follows: No matching children = return null. At least one child = return a String array of 0 length.

See Also:
Constant Field Values

LIST_BY_SIZE

public static final int LIST_BY_SIZE
See Also:
Constant Field Values

INFO_ICON

public static final int INFO_ICON
This requests the icon for the file - returns an IImage object. sourceParameters - none, resultDestination - unused, options - INFO_ICON_SMALL, INFO_ICON_MEDIUM, INFO_ICON_LARGE. Returns null if no icon could be found.

See Also:
Constant Field Values

INFO_ICON_SMALL

public static final int INFO_ICON_SMALL
See Also:
Constant Field Values

INFO_ICON_MEDIUM

public static final int INFO_ICON_MEDIUM
See Also:
Constant Field Values

INFO_ICON_LARGE

public static final int INFO_ICON_LARGE
See Also:
Constant Field Values

INFO_ROOT_LIST

public static final int INFO_ROOT_LIST
This requests the names of the root directory of all drives - returns an array of Strings. sourceParameters - none, resultDestination - unused, options - none defined yet. If this is not supported (e.g. under WinCE) it will return null and this implies that there is only one root i.e. "/"

See Also:
Constant Field Values

INFO_LINK_DESTINATION

public static final int INFO_LINK_DESTINATION
NOT IMPLEMENTED YET. If this File is considered a link/shortcut to another file or directory, this will return the name of the target file/directory, otherwise it will return null. sourceParamerters - none, resultDestination - unused, options - none defined yet.

See Also:
Constant Field Values

INFO_PROGRAM_DIRECTORY

public static final int INFO_PROGRAM_DIRECTORY
This returns a String which is the directory where the program is installed. Under Java, if this cannot be determined, then the current working directory is returned. This is provided because there is no concept of "Current Working Directory" in WindowsCE.

See Also:
Constant Field Values

INFO_TEMPORARY_DIRECTORY

public static final int INFO_TEMPORARY_DIRECTORY
This returns a String which is the directory where temporary files can be created.

See Also:
Constant Field Values

INFO_DEVICE_NAME

public static final int INFO_DEVICE_NAME
This returns a String which is the name of the computer.

See Also:
Constant Field Values

INFO_FLAGS

public static final int INFO_FLAGS
This gets a set of File or device specific flags. For FLAG_SLOW_ACCESS indicates that directory access/listing on this device is very slow (e.g. over a serial line).

See Also:
Constant Field Values

FLAG_SLOW_LIST

public static final int FLAG_SLOW_LIST
See Also:
Constant Field Values

FLAG_SLOW_CHILD_COUNT

public static final int FLAG_SLOW_CHILD_COUNT
See Also:
Constant Field Values

FLAG_SLOW_ACCESS

public static final int FLAG_SLOW_ACCESS
This is a flag returned from getInfo(INFO_FLAGS);

See Also:
Constant Field Values

FLAG_READ_ONLY

public static final int FLAG_READ_ONLY
Deprecated. - use getPermissionsAndFlags() and changePermissionsAndFlags()

This is a flag returned from getInfo(INFO_FLAGS);

See Also:
Constant Field Values

FLAG_FILE_SYSTEM_IS_READ_ONLY

public static final int FLAG_FILE_SYSTEM_IS_READ_ONLY
This is a flag returned from getInfo(INFO_FLAGS);

See Also:
Constant Field Values

FLAG_CASE_SENSITIVE

public static final int FLAG_CASE_SENSITIVE
This is a flag returned from getInfo(INFO_FLAGS);

See Also:
Constant Field Values

INFO_DEVICE_ICON

public static final int INFO_DEVICE_ICON
This returns an IImage representing the device on which the file is stored.

See Also:
Constant Field Values

INFO_FREE_DRIVE_SPACE

public static final int INFO_FREE_DRIVE_SPACE
This returns a Long specifying the number of free bytes on the disk, or null if it cannot be determined.

See Also:
Constant Field Values

INFO_TOTAL_DRIVE_SPACE

public static final int INFO_TOTAL_DRIVE_SPACE
This returns a Long specifying the total number of bytes on the the disk, or null if it cannot be determined.

See Also:
Constant Field Values

INFO_DETAIL_NAMES

public static final int INFO_DETAIL_NAMES
This should return an array of Strings giving the details to display about a file in the filechooser box. It should not include the name of the file - which is always displayed.

See Also:
Constant Field Values

INFO_DETAIL_WIDTHS

public static final int INFO_DETAIL_WIDTHS
This should return EITHER an array of ints giving the width of each detail column (except for name) or an array of Strings which represent the widest string expected for each column. You should provide a PropertyList with an entry for "fontMetrics" being the FontMetrics being used by the table.

See Also:
Constant Field Values

INFO_TOOL_TIP

public static final int INFO_TOOL_TIP
This should return a String representing a "tool-tip" to display for a file in the Filechooser box.

See Also:
Constant Field Values

INFO_DETAILS

public static final int INFO_DETAILS
This should return a String a particular detail for the file.

See Also:
Constant Field Values

INFO_OWNER

public static final int INFO_OWNER
This is used to get/set the owner of a file. The object returned with getInfo() is dependent on the operating system, but if toString() is called on the returned object it will return a value that equates to the user name of the owner (as on Unix) systems. If getInfo() returns null this indicates that the OS does not keep owner information on files.

See Also:
Constant Field Values

INFO_FILE_TIMES

public static final int INFO_FILE_TIMES
This is used to get/set the three file times for a file - the creation date, the last modification date and the last access date, in that order.

For a getInfo() operation the resultDestination should be an array of 3 Time objects, initially all null. On return the dates that are available on that system will be placed in the array in the order shown. If any of the values are null then that date is unknown on the system.

With a setInfo() operation the sourceParameter should again be an array of 3 Time objects, with with any value that you do not wish to set being null.

See Also:
Constant Field Values

INFO_GROUP

public static final int INFO_GROUP
This is used to get/set the group of a file. The object returned with getInfo() is dependent on the operating system, but if toString() is called on the returned object it will return a value that equates to the user name of the group (as on Unix) systems. If getInfo() returns null this indicates that the OS does not keep group information on files.

See Also:
Constant Field Values

INFO_SYSTEM_TYPE

public static final int INFO_SYSTEM_TYPE
Used for getting the file system type. Use null sourceParameters and resultDestination. The value returned by getInfo() will be a ewe.sys.Long which holds one of the FileSys.XXX_SYSTEM values - or null if the type could not be determined.

See Also:
Constant Field Values

separatorChar

public static final char separatorChar

pathSeparatorChar

public static final char pathSeparatorChar

separator

public static final String separator

pathSeparator

public static final String pathSeparator
Constructor Detail

FileBase

protected FileBase()
Method Detail

getIcon

public static IImage getIcon(int whichIcon)
Get one of the icons: OpenFolderIcon, ClosedFolderIcon and PageIcon.


set

public abstract void set(File directory,
                         String path)
Modifies the File to point to a different file on the file system. This means that ewe.io.File objects are not immutable, but this avoids a lot of object creation when dealing with large directories.


getNewInstance

protected abstract File getNewInstance()

getNew

public File getNew(File directory,
                   String path)
Get a new File object given the directory and new path. This is for objects which inherit from File. The default implementation of this will call getNewInstance() and then call set(File directory,String path). If you do not override getNew() you must override getNewInstance().


createDir

public abstract boolean createDir()
Creates a directory. Returns true if the operation is successful and false otherwise.


delete

public abstract boolean delete()
Deletes the file or directory. Returns true if the operation is successful and false otherwise.


exists

public abstract boolean exists()
Returns true if the file exists and false otherwise.


isDirectory

public abstract boolean isDirectory()
Returns true if the file is a directory and false otherwise.


getFullPath

public abstract String getFullPath()
Return the fully qualified pathname of the file. Note that this will never end with a "/" EXCEPT for the root directory on a disk.


deleteOnExit

public abstract void deleteOnExit()
This tells the system to delete the file when the program exits.


list

public String[] list(String mask,
                     int listAndSortOptions)
Lists the files contained in a directory. The strings returned are the names of the files and directories contained within this directory. This method returns null if the directory can't be read or if the operation fails. If mask is null or "*" then all files will be listed.

This method calls the asynchronous listFiles() method and then waits for the handle to complete. You should override the listFiles() method for classes that inherit from FileBase.

Parameters:
mask - A file mask.
listAndSortOptions - Use the LIST_XXX values OR'ed together.
Returns:
An array of file names.

listMultiple

public String[] listMultiple(String compositeMask,
                             int listAndSortOptions)
Lists the files contained in a directory using a complex mask - which may actually consist of multiple masks (e.g. "*.jpg,*.gif - Image Files.").

Parameters:
compositeMask - A possibly complex file mask.
listAndSortOptions - Use the LIST_XXX values OR'ed together.
Returns:
An array of file names.

listFiles

public abstract Handle listFiles(String mask,
                                 int listAndSortOptions)
List files asynchronously. NOTE: version 1.16 of Ewe does not list the files asynchronously - it is synchronous. Therefore it always returns a Handle that is completed.

By default this method calls the doList() method and then returns a completed Handle that either indicates success or failure. Methods that inherit from FileBase are encouraged to provide a better version of this (preferrable one that spawns a thread).

Parameters:
mask - The a file maks using '*' characters.
listAndSortOptions - LIST_ and SORT_ options ORed together.
Returns:
A Handle which can be used to monitor the progress of the operation.

getSetModified

protected abstract void getSetModified(Time time,
                                       boolean doGet)
This gets/sets the modified time of the file. should not exist.


move

public abstract boolean move(File newFile)
This moves/renames the file to the destination new File. The new File should not exist.


toSystemDependantPath

public static String toSystemDependantPath(String path)
This converts any '/' directory separators to the one that is native to the running OS (ie '\' on Windows) and any ';' path separtors to the one that is native to the running OS (ie ':' on Unix/Linux).

Your initial constructed path(s) SHOULD use '/' for directories and ';' for path separators.

This is generally only necessary for a few system dependant functions and is not necessary for standard file access.


renameTo

public boolean renameTo(File newFile)

lastModified

public long lastModified()

setLastModified

public boolean setLastModified(long time)

list

public String[] list()
Lists all files on the directory that this File object represents, sorted by name - with directories listed first. This simply calls the list(String mask,int listAndSortOptions) method with the parameters null and 0.


list

public String[] list(FilenameFilter filter)
List all files in this directory using the specified filter.

Parameters:
filter - The filter to use for accepting/rejecting files.
Returns:
An array of file names that satisfy the filter.

getNew

public File getNew(String path)
Get a new File object given the directory and new path. This is for objects which inherit from File.


getChild

public File getChild(String path)

canRead

public boolean canRead()
Returns true if the file exists and can be read.


canWrite

public boolean canWrite()

isFile

public boolean isFile()

getCreationName

public String getCreationName()
Return the file's path, as specified when created.


isHidden

public boolean isHidden()

getFileExt

public String getFileExt()
Return only the filename and extension of the file.


getDrivePath

public String getDrivePath()
Return only the drive and path of the file.


getFileExt

public static String getFileExt(String str)

getDrivePath

public static String getDrivePath(String str)

makePath

public static String makePath(File parent,
                              String child)
Utility to create a path name given a parent and child.

Parameters:
parent - The parent File - which may be null.
child - The child name.
Returns:
The correct path name representing the child within the parent directory.

makePath

public static String makePath(String parent,
                              String child)
Utility to create a path name given a parent and child.

Parameters:
parent - The parent path - which may be null.
child - The child name.
Returns:
The correct path name representing the child within the parent directory.

getParent

public String getParent()

getParentFile

public File getParentFile()
Get a File object representing the parent direcotry of this File. This is provided so you don't have to decypher the path. Returns null if there is no parent.


createTempFile

public File createTempFile(String prefix,
                           String suffix,
                           File dir)
This creates an empty temporary file with the specified prefix and suffix. If the suffix is null then ".tmp" will be used. If the dir is null, the system temporary folder will be used. Note that this method may return a file name that is different from the requested file name. This depends on the underlying system and how it provides temporary file support.

Overrides:
createTempFile in class FileSys

createTempFile

public File createTempFile(String fileName,
                           File dir)
This creates an empty file with a specific name in a temporary directory. If the file already exists in the directory it will be deleted and the new one will be created. If dir is null then the file will be created in the system temporary directory.

Overrides:
createTempFile in class FileSys

rename

public boolean rename(String newName)
This renames the file in place. It does not move or change the directory of the file. The newName parameter is a single name without directory specifiers within it.


getModified

public Time getModified(Time dest)
Return the Time the File was last modified.

Parameters:
dest - an optional destination Time. If it is null a new one will be created and returned.
Returns:
the destination Time or a new one if it was null.

setModified

public void setModified(Time modifiedTime)
Set the last modified time for the file.

Parameters:
modifiedTime - the time to set as the last modified time.

getInfo

public Object getInfo(int infoCode)

getFlags

public int getFlags()
A quick way to get the flags from getInfo().


getInfo

public abstract Object getInfo(int infoCode,
                               Object sourceParameters,
                               Object resultDestination,
                               int options)
This method is used to get extended information about the File or the File system in general. It is used with the INFO_ specifiers and options.

Parameters:
infoCode - one of the INFO_ codes.
sourceParameters - A (possibly null) object giving more details for the information to get. The Object used depends on the infoCode.
resultDestination - A (possibly null) object to be used as the destination for the results. The Object used depends on the infoCode.
options - Options or possibly an index value for the info to get.
Returns:
An Object with the required information. If it is a Throwable object then it indicates an error. If it is a Handle, this indicates that the operation requires time to complete and that the actual result will be placed in the Handle when done. If it is null this indicates a general failure.

setInfo

public Handle setInfo(int infoCode,
                      Object sourceParameters,
                      int options)
This is used to set extended information about the File or the File system in general. It is used with some of the INFO_ values.

Parameters:
infoCode - One of a few INFO_values.
sourceParameters - The information to set. The object used is dependent on the infoCode.
options - Options or possible an index value for the info to set.
Returns:
A Handle that can be used to monitor the progress or success of the operation. Call check() on the handle to see if the Handle.Success or Handle.Failure flags are set. If the Handle.Running flag is set, then the operation has not yet completed.

setInfo

public boolean setInfo(int infoCode,
                       Object sourceParameters,
                       Object resultDesination,
                       int options)
Deprecated. use the other setInfo() instead.

This method is used to set extended information about the File or the File system in general. It is used with the INFO_ specifiers and options.


getProgramDirectory

public static String getProgramDirectory()
A quick way to get the program directory for the application.


listRoots

public static File[] listRoots()
List all the root files in the default file system. This will return null if the roots could not be determined (e.g. under Java 1.1)

Returns:
an array of File objects representing the available roots.

mkdirs

public boolean mkdirs()
Create a directory and all necessary parent directories. Returns false if it could not create the directory, true if it can or if it already exists.


mkdir

public boolean mkdir()

toString

public String toString()
Description copied from class: Object
Return a String representation of this object.

Overrides:
toString in class Object
Returns:
a String representing this object.

fixupPath

public static String fixupPath(String path)

removeTrailingSlash

public static String removeTrailingSlash(String path)

equals

public boolean equals(Object other)
This checks to see if the two files refer to the same object in the file system. Currently it does that by comparing their full paths.

Overrides:
equals in class Object
Parameters:
other - Another object to compare to.
Returns:
true if this object is considered equal to the other object.

hashCode

public int hashCode()
Description copied from class: Object
Returns a hashCode for the object. The general contract of hashCode is:
  • An object must return the same hash code for its entire existence.
  • If two objects are considered equal by the equals() method, they should return the same hash code. Not all Objects will do this and you should only use hashCode() from Objects which declare an overrided version of hashCode(). The only Objects which provide consistent and correct hash codes under Ewe are Object, String and Class.

    Overrides:
    hashCode in class Object

  • filePathsAreEqual

    public boolean filePathsAreEqual(String one,
                                     String two)

    getText

    public String getText()
    Specified by:
    getText in interface Textable

    setText

    public void setText(String text)
    Specified by:
    setText in interface Textable

    getAbsolutePath

    public String getAbsolutePath()
    This differs from getFullPath() in that this will convert all '\' characters to '/' characters.


    getAbsoluteFile

    public File getAbsoluteFile()

    getCanonicalPath

    public String getCanonicalPath()
                            throws IOException
    Throws:
    IOException

    getCanonicalFile

    public File getCanonicalFile()
                          throws IOException
    Throws:
    IOException

    getName

    public String getName()
    Description copied from interface: Streamable
    Get the name associated with this Streamable object.

    Specified by:
    getName in interface Streamable

    getPath

    public String getPath()

    refresh

    public Handle refresh()
    This tells the File system to consider any cached directory invalid so so that a list() call will do a true lookup.

    Returns:
    A Handle indicating the progress of the refresh.

    isSameFileSystem

    public boolean isSameFileSystem(File other)
    Returns true if the other file system is considered the same as this one. By default this compares the class names of this File and the other File and returns true if they are equal.

    Parameters:
    other - another File object representing a File on a possibly different file system.
    Returns:
    true if the two File objects are considered to be on the same system.

    isSameVolume

    public boolean isSameVolume(File other)
    Checks if the volume which contains the other File is considered the same as the one that contains this File. Generally move() operations will not succeed across volumes.

    Parameters:
    other - another File object representing a File on a possibly different volume.
    Returns:
    true if the two File objects are considered to be on the same file system and the same volume.

    getTrueParent

    public static File getTrueParent(File parent,
                                     String child,
                                     File aFile)

    getTrueChild

    public static String getTrueChild(File parent,
                                      String child,
                                      File aFile)

    convertMode

    public static int convertMode(String mode)
    A utility method to convert from "r" or "rw" to READ_ONLY or READ_WRITE mode. It will throw an IllegalArgumentException if the mode is not one of these two.

    Parameters:
    mode - must be "r" or "rw"
    Returns:
    READ_ONLY or READ_WRITE.
    Throws:
    IllegalArgumentException - if mode is not "r" or "rw"

    toStream

    public Handle toStream(boolean isRandom,
                           String type)
                    throws IllegalArgumentException
    Description copied from interface: Streamable
    Requests the possibly asynchronous creation of a Stream object for reading or writing.

    Specified by:
    toStream in interface Streamable
    Parameters:
    isRandom - if this is true then a request is being made for a RandomAccessStream, otherwise either a readable or writable Stream will be returned.
    type - For RandomAccessStreams this can be "r" or "rw". For writable Streams this should be "w" or "a" (for append) and for readable Streams it should be "r".
    Returns:
    A Handle used to form monitoring the creation process and for retrieving the final value.

    The calling code should wait on the Handle.Success flag to be set. If this happens the returnValue of the Handle will be set to the acquired Stream. If the Handle fails then the errorObject of the Handle will be set to an IOException.

    Throws:
    IllegalArgumentException - if the mode is incorrect.

    toReadableStream

    public Stream toReadableStream()
                            throws IOException
    Create and return a Stream to use for reading from the File.

    Returns:
    An open Steam that can be used for reading from the File.
    Throws:
    IOException - if an open stream could not be created.

    toWritableStream

    public Stream toWritableStream(boolean append)
                            throws IOException
    Create and return a Stream to use for writing to the File. If the file does not exist it will be created.

    Parameters:
    append - set this true if you want to append to the existing file.
    Returns:
    An open Steam that can be used for reading from the File.
    Throws:
    IOException - if an open stream could not be created, or if the file exists but could not be written to or erased (if not appending), or if you requested append but append mode is not supported for this File.

    getInputStream

    public final Stream getInputStream()
    Deprecated. use toReadableStream() instead.

    Get a stream to read from the File.

    Returns:
    A stream to read from, or null if a stream could not be opened.

    getOutputStream

    public final Stream getOutputStream()
    Deprecated. use toWritableStream() instead.

    Get a stream to write to the File.

    Returns:
    A stream to write to, or null if a stream could not be opened.

    getRandomAccessStream

    public final RandomAccessStream getRandomAccessStream(int mode)
    Deprecated. use toRandomAccessStream() instead.

    Get a RandomAccessStream for the file.


    toRandomAccessStream

    public RandomAccessStream toRandomAccessStream(String mode)
                                            throws IOException
    Create and return a RandomAccessStream for reading/writing to the data associated with this File object.

    Parameters:
    mode - must be "r" or "rw".
    Returns:
    An open RandomAccessStream
    Throws:
    IOException - if an open stream could not be created.
    IllegalArgument - exception if mode is not "r" or "rw"

    getNewFile

    public static File getNewFile()
    Get a new File object for the default file system used by the VM.


    getNewFile

    public static File getNewFile(String name)
    Get a new File object for the default file system used by the VM.


    getNewFile

    public static File getNewFile(File directory,
                                  String name)
    Get a new File object for the default file system used by the VM.


    getPermissionsAndFlags

    public int getPermissionsAndFlags(int interestedFlags)
                               throws IOException,
                                      IllegalArgumentException
    Get ther permissions/flags for this File - see ewe.io.FilePermissions for a list of the available flag permissions.

    Parameters:
    interestedFlags - The flags whose values you are interested in.
    Returns:
    The permission/flag types ORed together.
    Throws:
    IOException - if the file does not exist or some other error occured.
    IllegalArgumentException - if one of the flags you are interested in is not supported on this file system.

    changePermissionsAndFlags

    public boolean changePermissionsAndFlags(int valuesToSet,
                                             int valuesToClear)
                                      throws IOException,
                                             IllegalArgumentException
    Change ther permissions/flags for this File - see ewe.io.FilePermissions for a list of the available flag permissions.

    Parameters:
    valuesToSet - The permissions/flags to set.
    valuesToClear - The permissions/flags to clear.
    Returns:
    true if all the requested changes were made, false if not.
    Throws:
    IOException - if the file does not exist or some other IO error occured.
    IllegalArgumentException - if one of the flag values is not supported.

    getSetPermissionsAndFlags

    protected int getSetPermissionsAndFlags(boolean isGet,
                                            int valuesToSetOrGet,
                                            int valuesToClear)
                                     throws IOException,
                                            IllegalArgumentException
    This is used to implement getPermissionsAndFlags() and changePermissionsAndFlags(). It should work like this:

    If isGet is true, then the valuesToSetOrGet parameter will hold the flags that the user is interested in. If any of these flags are invalid on this system an IllegalArgumentException should be thrown. Otherwise the current state of the flags should be returned - it is OK to return extra flags even if they are not specified as flags the user is interested in.

    If isGet is false, then the valuesToSetOrGet parameter will hold the flags to set and the valuesToClear parameter will hold the flags to clear. If any of these are not valid then an IllegalArgumentException should be thrown. Otherwise the flags should be changed and then the state of the flags AFTER the change has been made should be returned.

    Throws:
    IOException
    IllegalArgumentException

    getLength

    public abstract int getLength()

    getPropertiesString

    public String getPropertiesString()
                               throws IOException
    Throws:
    IOException