ewe.io
Class File

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

public class File
extends FileBase

File is a file or directory (similar to the Java File) - it is not used for I/O. Use RandomAccessFile for file I/O or File.getInputStream(), File.getOutputStream() instead.

The File class will not work under the PalmPilot since it does not contain a filesystem.

Note that ewe.io.File objects ARE mutable. The set() method may be used to change the file which is being referred to.


Field Summary
 
Fields inherited from class ewe.io.FileBase
ClosedFolderIcon, CREATE, DriveIcon, FileIcon, FLAG_CASE_SENSITIVE, FLAG_FILE_SYSTEM_IS_READ_ONLY, FLAG_READ_ONLY, FLAG_SLOW_ACCESS, FLAG_SLOW_CHILD_COUNT, FLAG_SLOW_LIST, INFO_DETAIL_NAMES, INFO_DETAIL_WIDTHS, INFO_DETAILS, INFO_DEVICE_ICON, INFO_DEVICE_NAME, INFO_FILE_TIMES, INFO_FLAGS, INFO_FREE_DRIVE_SPACE, INFO_GROUP, INFO_ICON, INFO_ICON_LARGE, INFO_ICON_MEDIUM, INFO_ICON_SMALL, INFO_LINK_DESTINATION, INFO_OWNER, INFO_PROGRAM_DIRECTORY, INFO_ROOT_LIST, INFO_SYSTEM_TYPE, INFO_TEMPORARY_DIRECTORY, INFO_TOOL_TIP, INFO_TOTAL_DRIVE_SPACE, LIST_ALWAYS_INCLUDE_DIRECTORIES, LIST_BY_DATE, LIST_BY_SIZE, LIST_BY_TYPE, LIST_CHECK_FOR_ANY_MATCHING_CHILDREN, LIST_DESCENDING, LIST_DIRECTORIES_LAST, LIST_DIRECTORIES_ONLY, LIST_DONT_SORT, LIST_FILES_ONLY, LIST_IGNORE_DIRECTORY_STATUS, name, OpenFolderIcon, PageIcon, pathSeparator, pathSeparatorChar, READ_ONLY, READ_WRITE, separator, separatorChar, WRITE_ONLY
 
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 File()
           
  File(File parent, String path)
          Create a File Object which represents a file on the file system under the specified parent directory.
  File(String path)
          Create a File Object which represents a file on the file system.
  File(String parent, String path)
          Create a File Object which represents a file on the file system under the specified parent directory.
 
Method Summary
 boolean createDir()
          Creates a directory.
 boolean delete()
          Deletes the file or directory.
 void deleteOnExit()
          This tells the system to delete the file when the program exits.
 boolean executeFileChooser(FileChooserParameters fcp)
           
 boolean exists()
          Returns true if the file exists and false otherwise.
static String getFileChooserClass()
           
 String getFullPath()
          Return the fully qualified pathname of the file.
 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.
 int getLength()
          Returns the length of the file in bytes.
protected  File getNewInstance()
           
protected  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().
 boolean isDirectory()
          Returns true if the file is a directory and false otherwise.
 long length()
          Return the length of the file in bytes.
 Handle listFiles(String mask, int listAndSortOptions)
          List files asynchronously.
 boolean move(File newFile)
          This moves/renames the file to the destination newFile.
protected  Object nativeGetInfo(int infoCode, Object sourceParameters, Object resultDestination, int options)
           
protected  boolean nativeSetInfo(int infoCode, Object sourceParameters, int options)
           
 void set(File directory, String path)
          Modifies the File to point to a different file on the file system.
static void setFileChooserClass(String className)
           
 Handle setInfo(int infoCode, Object sourceParameters, int options)
          This is used to set extended information about the File or the File system in general.
 
Methods inherited from class ewe.io.FileBase
canRead, canWrite, changePermissionsAndFlags, convertMode, createTempFile, createTempFile, equals, filePathsAreEqual, fixupPath, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getChild, getCreationName, getDrivePath, getDrivePath, getFileExt, getFileExt, getFlags, getIcon, getInfo, getInputStream, getModified, getName, getNew, getNew, getNewFile, getNewFile, getNewFile, getOutputStream, getParent, getParentFile, getPath, getPermissionsAndFlags, getProgramDirectory, getPropertiesString, getRandomAccessStream, getText, getTrueChild, getTrueParent, hashCode, isFile, isHidden, isSameFileSystem, isSameVolume, lastModified, list, list, list, listMultiple, listRoots, makePath, makePath, mkdir, mkdirs, refresh, removeTrailingSlash, rename, renameTo, setInfo, setLastModified, setModified, setText, toRandomAccessStream, toReadableStream, toStream, toString, toSystemDependantPath, toWritableStream
 
Methods inherited from class java.lang.Object
clone, finalize, getClass
 

Constructor Detail

File

protected File()

File

public File(String path)
Create a File Object which represents a file on the file system. The file name may specify a file or directory which may or may not exist. Please note that under WindowsCE there is no concept of "Current Working Directory". All file names must have a full path. If you want a file or directory to co-exist within the same directory that your ewe program was installed by the user, then use the call: String pd = (String)new File("").getInfo(File.INFO_PROGRAM_DIRECTORY,null,null,0); File programDirectory = new File(pd); Then use programDirectory as the parent directory for your data files/directories.


File

public File(File parent,
            String path)
Create a File Object which represents a file on the file system under the specified parent directory. The resulting file may be a file or directory which may or may not exist. The parent directory MAY be null - in which case the path must specify the file fully. Please note that under WindowsCE there is no concept of "Current Working Directory". All file names must have a full path. If you want a file or directory to co-exist within the same directory that your ewe program was installed by the user, then use the call: String pd = File.getProgramDirectory(); File programDirectory = new File(pd); Then use programDirectory as the parent directory for your data files/directories.


File

public File(String parent,
            String path)
Create a File Object which represents a file on the file system under the specified parent directory. The resulting file may be a file or directory which may or may not exist. The parent directory MAY be null - in which case the path must specify the file fully. Please note that under WindowsCE there is no concept of "Current Working Directory". All file names must have a full path. If you want a file or directory to co-exist within the same directory that your ewe program was installed by the user, then use the call: String pd = File.getProgramDirectory(); File programDirectory = new File(pd); Then use programDirectory as the parent directory for your data files/directories.

Method Detail

getNewInstance

protected File getNewInstance()
Specified by:
getNewInstance in class FileBase

set

public 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.

Specified by:
set in class FileBase

createDir

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

Specified by:
createDir in class FileBase

delete

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

Specified by:
delete in class FileBase

exists

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

Specified by:
exists in class FileBase

getLength

public int getLength()
Returns the length of the file in bytes.

Specified by:
getLength in class FileBase

listFiles

public 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).

Specified by:
listFiles in class FileBase
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.

length

public long length()
Return the length of the file in bytes.


getFullPath

public 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.

Specified by:
getFullPath in class FileBase

isDirectory

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

Specified by:
isDirectory in class FileBase

move

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

Specified by:
move in class FileBase

deleteOnExit

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

Specified by:
deleteOnExit in class FileBase

getSetModified

protected void getSetModified(Time time,
                              boolean doGet)
Description copied from class: FileBase
This gets/sets the modified time of the file. should not exist.

Specified by:
getSetModified in class FileBase

getInfo

public 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.

Specified by:
getInfo in class FileBase
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.

nativeGetInfo

protected Object nativeGetInfo(int infoCode,
                               Object sourceParameters,
                               Object resultDestination,
                               int options)

setInfo

public Handle setInfo(int infoCode,
                      Object sourceParameters,
                      int options)
Description copied from class: FileBase
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.

Overrides:
setInfo in class FileBase
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.

nativeSetInfo

protected boolean nativeSetInfo(int infoCode,
                                Object sourceParameters,
                                int options)

getSetPermissionsAndFlags

protected int getSetPermissionsAndFlags(boolean isGet,
                                        int valuesToSetOrGet,
                                        int valuesToClear)
                                 throws IOException,
                                        IllegalArgumentException
Description copied from class: FileBase
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.

Overrides:
getSetPermissionsAndFlags in class FileBase
Throws:
IOException
IllegalArgumentException

setFileChooserClass

public static void setFileChooserClass(String className)

getFileChooserClass

public static String getFileChooserClass()

executeFileChooser

public boolean executeFileChooser(FileChooserParameters fcp)
                           throws IllegalStateException
Throws:
IllegalStateException