|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.io.FileSys
ewe.io.FileBase
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 |
protected String name
public static final int OpenFolderIcon
public static final int ClosedFolderIcon
public static final int PageIcon
public static final int FileIcon
public static final int DriveIcon
public static final int READ_ONLY
public static final int WRITE_ONLY
public static final int READ_WRITE
public static final int CREATE
public static final int LIST_DESCENDING
public static final int LIST_DIRECTORIES_LAST
public static final int LIST_DIRECTORIES_ONLY
public static final int LIST_FILES_ONLY
public static final int LIST_BY_DATE
public static final int LIST_BY_TYPE
public static final int LIST_DONT_SORT
public static final int LIST_IGNORE_DIRECTORY_STATUS
public static final int LIST_ALWAYS_INCLUDE_DIRECTORIES
public static final int LIST_CHECK_FOR_ANY_MATCHING_CHILDREN
public static final int LIST_BY_SIZE
public static final int INFO_ICON
public static final int INFO_ICON_SMALL
public static final int INFO_ICON_MEDIUM
public static final int INFO_ICON_LARGE
public static final int INFO_ROOT_LIST
public static final int INFO_LINK_DESTINATION
public static final int INFO_PROGRAM_DIRECTORY
public static final int INFO_TEMPORARY_DIRECTORY
public static final int INFO_DEVICE_NAME
public static final int INFO_FLAGS
public static final int FLAG_SLOW_LIST
public static final int FLAG_SLOW_CHILD_COUNT
public static final int FLAG_SLOW_ACCESS
public static final int FLAG_READ_ONLY
public static final int FLAG_FILE_SYSTEM_IS_READ_ONLY
public static final int FLAG_CASE_SENSITIVE
public static final int INFO_DEVICE_ICON
public static final int INFO_FREE_DRIVE_SPACE
public static final int INFO_TOTAL_DRIVE_SPACE
public static final int INFO_DETAIL_NAMES
public static final int INFO_DETAIL_WIDTHS
public static final int INFO_TOOL_TIP
public static final int INFO_DETAILS
public static final int INFO_OWNER
public static final int INFO_FILE_TIMES
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.
public static final int INFO_GROUP
public static final int INFO_SYSTEM_TYPE
public static final char separatorChar
public static final char pathSeparatorChar
public static final String separator
public static final String pathSeparator
| Constructor Detail |
protected FileBase()
| Method Detail |
public static IImage getIcon(int whichIcon)
public abstract void set(File directory,
String path)
protected abstract File getNewInstance()
public File getNew(File directory,
String path)
public abstract boolean createDir()
public abstract boolean delete()
public abstract boolean exists()
public abstract boolean isDirectory()
public abstract String getFullPath()
public abstract void deleteOnExit()
public String[] list(String mask,
int listAndSortOptions)
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.
mask - A file mask.listAndSortOptions - Use the LIST_XXX values OR'ed together.
public String[] listMultiple(String compositeMask,
int listAndSortOptions)
compositeMask - A possibly complex file mask.listAndSortOptions - Use the LIST_XXX values OR'ed together.
public abstract Handle listFiles(String mask,
int listAndSortOptions)
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).
mask - The a file maks using '*' characters.listAndSortOptions - LIST_ and SORT_ options ORed together.
protected abstract void getSetModified(Time time,
boolean doGet)
public abstract boolean move(File newFile)
public static String toSystemDependantPath(String path)
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.
public boolean renameTo(File newFile)
public long lastModified()
public boolean setLastModified(long time)
public String[] list()
public String[] list(FilenameFilter filter)
filter - The filter to use for accepting/rejecting files.
public File getNew(String path)
public File getChild(String path)
public boolean canRead()
public boolean canWrite()
public boolean isFile()
public String getCreationName()
public boolean isHidden()
public String getFileExt()
public String getDrivePath()
public static String getFileExt(String str)
public static String getDrivePath(String str)
public static String makePath(File parent,
String child)
parent - The parent File - which may be null.child - The child name.
public static String makePath(String parent,
String child)
parent - The parent path - which may be null.child - The child name.
public String getParent()
public File getParentFile()
public File createTempFile(String prefix,
String suffix,
File dir)
createTempFile in class FileSys
public File createTempFile(String fileName,
File dir)
createTempFile in class FileSyspublic boolean rename(String newName)
public Time getModified(Time dest)
dest - an optional destination Time. If it is null a new one will be
created and returned.
public void setModified(Time modifiedTime)
modifiedTime - the time to set as the last modified time.public Object getInfo(int infoCode)
public int getFlags()
public abstract Object getInfo(int infoCode,
Object sourceParameters,
Object resultDestination,
int options)
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.
public Handle setInfo(int infoCode,
Object sourceParameters,
int options)
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.
public boolean setInfo(int infoCode,
Object sourceParameters,
Object resultDesination,
int options)
public static String getProgramDirectory()
public static File[] listRoots()
public boolean mkdirs()
public boolean mkdir()
public String toString()
Object
toString in class Objectpublic static String fixupPath(String path)
public static String removeTrailingSlash(String path)
public boolean equals(Object other)
equals in class Objectother - Another object to compare to.
public int hashCode()
Object
hashCode in class Object
public boolean filePathsAreEqual(String one,
String two)
public String getText()
getText in interface Textablepublic void setText(String text)
setText in interface Textablepublic String getAbsolutePath()
public File getAbsoluteFile()
public String getCanonicalPath()
throws IOException
IOException
public File getCanonicalFile()
throws IOException
IOExceptionpublic String getName()
Streamable
getName in interface Streamablepublic String getPath()
public Handle refresh()
public boolean isSameFileSystem(File other)
other - another File object representing a File on a possibly different file system.
public boolean isSameVolume(File other)
other - another File object representing a File on a possibly different volume.
public static File getTrueParent(File parent,
String child,
File aFile)
public static String getTrueChild(File parent,
String child,
File aFile)
public static int convertMode(String mode)
mode - must be "r" or "rw"
IllegalArgumentException - if mode is not "r" or "rw"
public Handle toStream(boolean isRandom,
String type)
throws IllegalArgumentException
Streamable
toStream in interface StreamableisRandom - 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".
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.
IllegalArgumentException - if the mode is incorrect.
public Stream toReadableStream()
throws IOException
IOException - if an open stream could not be created.
public Stream toWritableStream(boolean append)
throws IOException
append - set this true if you want to append to the existing file.
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.public final Stream getInputStream()
public final Stream getOutputStream()
public final RandomAccessStream getRandomAccessStream(int mode)
public RandomAccessStream toRandomAccessStream(String mode)
throws IOException
mode - must be "r" or "rw".
IOException - if an open stream could not be created.
IllegalArgument - exception if mode is not "r" or "rw"public static File getNewFile()
public static File getNewFile(String name)
public static File getNewFile(File directory,
String name)
public int getPermissionsAndFlags(int interestedFlags)
throws IOException,
IllegalArgumentException
interestedFlags - The flags whose values you are interested in.
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.
public boolean changePermissionsAndFlags(int valuesToSet,
int valuesToClear)
throws IOException,
IllegalArgumentException
valuesToSet - The permissions/flags to set.valuesToClear - The permissions/flags to clear.
IOException - if the file does not exist or some other IO error occured.
IllegalArgumentException - if one of the flag values is not supported.
protected int getSetPermissionsAndFlags(boolean isGet,
int valuesToSetOrGet,
int valuesToClear)
throws IOException,
IllegalArgumentException
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.
IOException
IllegalArgumentExceptionpublic abstract int getLength()
public String getPropertiesString()
throws IOException
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||