Class File

Object
   |
   +--File

class File


Class representing files and directories.

Objects of this class can refer to regular files, directories or archives of files. In the two latter cases, the object contains references to its subdirectories and files.

The fileSystem.mountPoint property and any mounted directories are File objects. You may make a File object by calling the resolve() method on any of these.

The File class is special in that it doubles as an array-like object containing the File objects it refers to. So if, a directory contains a series of files and directories, you can do the following:

var dir = mp.resolve('path/to/dir'); //Get a File object referring to the directory
dir.refresh(); //Load the contents of the directory
for ( var i = 0, file; file = dir[i]; i++ )
{
    opera.postError(file.name);
}

Defined in file-io.js


Field Summary
 Date created
          The time and date this File was created.
 boolean exists
          Whether or not this File exists in the physical file system.
 int fileSize
          The number of bytes in this File.
 boolean isArchive
          Whether or not this File is a compressed archive, like a zip or gzip file.
 boolean isDirectory
          Whether or not this File is a directory.
 boolean isFile
          Whether or not this File is a regular file.
 boolean isHidden
          Whether or not this File is hidden in the underlying file system.
 int length
          The number of files and directories referenced by this File.
 int maxPathLength
          The maximum number of characters a path reference can contain.
 Object metaData
          Meta data for this file.
 Date modified
          The time and date this File was last modified.
 String name
          The name of this File as a URL encoded String.
 String nativePath
          The path to this File in the physical file system.
 File parent
          The parent File of this File, or null if it has no parent.
 String path
          The path to this File in the virtual file system as a URL encoded String.
 boolean readOnly
          Whether or not this File is read only.
 
Constructor Summary
File()
            This class has no public constructor.
 
Method Summary
 File copyTo( <File> path, <boolean> overwrite, <Function> callback )
           Copy this File to the given File path.
 File createDirectory( <File> directory )
           Create a new directory.
 boolean deleteDirectory( <File> directory, <boolean> recursive )
           Delete the given directory.
 boolean deleteFile( <File> file )
           Delete the given file.
 File moveTo( <File> path, <boolean> overwrite, <Function> callback )
           Move this File to the given File path.
 FileStream open( <File> path, <int> mode )
           Open a File for reading or writing.
 void refresh()
           Refresh the content in this File.
 File resolve( <String> path )
           Resolve a path to a file.
 String toString()
           String representation of this File.

Field Detail

created

Date created

exists

boolean exists

fileSize

int fileSize

isArchive

boolean isArchive

isDirectory

boolean isDirectory

isFile

boolean isFile

isHidden

boolean isHidden

length

int length

maxPathLength

int maxPathLength

metaData

Object metaData

modified

Date modified

name

String name

nativePath

String nativePath

parent

File parent

path

String path

readOnly

boolean readOnly

Constructor Detail

File

File()

Method Detail

copyTo

File copyTo( <File> path, <boolean> overwrite, <Function> callback )

createDirectory

File createDirectory( <File> directory )

deleteDirectory

boolean deleteDirectory( <File> directory, <boolean> recursive )

deleteFile

boolean deleteFile( <File> file )

moveTo

File moveTo( <File> path, <boolean> overwrite, <Function> callback )

open

FileStream open( <File> path, <int> mode )

refresh

void refresh()

resolve

File resolve( <String> path )

toString

String toString()


Documentation generated by JSDoc on Fri Jan 29 17:08:19 2010