|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object | +--opera.io.filesystem
Virtual file system implementation
The FileSystem
class represents a virtual file system. Actual files are
connected to it by defining mount points from the actual file system. This
way file system access can be limited to a selected set of files rather
than allow unsecure operations on the local file system directly.
Path references in the virtual file systems always use '/' as the path separator.
Field Summary | |
File |
mountPoints
The mount points currently attached to this FileSystem . |
Constructor Summary | |
opera.io.filesystem()
This class has no public constructor. |
Method Summary | |
void
|
browseForDirectory( <String> name, <String> defaultlocation, <Function> callback, <boolean> persistent )
Open a dialog allowing the user to browse for a directory to mount. |
void
|
browseForFile( <String> name, <String> defaultlocation, <Function> callback, <boolean> persistent, <boolean> multiple, <Array> filter )
Open a dialog allowing the user to browse for a file to mount. |
void
|
browseForSave( <String> name, <String> defaultlocation, <Function> callback, <boolean> persistent )
Open a dialog allowing the user to create a new file, which is then mounted. |
File
|
mountSystemDirectory( <String> location, <String> name )
Mount application or storage system directory. |
void
|
removeMountPoint( <File> mountpoint )
Remove the given mount point. |
Field Detail |
File mountPoints
FileSystem
. Readonly.
This is a special File
object that represents the root of the virtual file
system and serves to enumerate the existing mount points. Its path is
/
and its name is empty. If you mount a directory as foo
, the path
of the mount point is /foo
.
Constructor Detail |
opera.io.filesystem()
Method Detail |
void browseForDirectory( <String> name, <String> defaultlocation, <Function> callback, <boolean> persistent )
Note that this method is not supported for Opera Unite applications.
Calling this function will open a file chooser dialog showing only directories. When the user
selects one, the directory is mounted and the given callback
is called with a File
object
representing the directory. If the user cancels the dialog, or if mounting fails, the callback
is called with a null argument.
Mount points are by default destroyed whenever the application is closed. If you give the persistent
argument as true
, the mount point will be remounted the next time the application is started.
The defaultlocation
argument is used to specify the initial directory of the dialog.
This function will only be called as a result of direct user interaction, such as a click event or similar. If called from a timeout or a programatically dispatched event, it will be ignored by the runtime.
Mount points are mounted as read-write, so you should take care to protect your data by limiting users' access to it.
name
- The name of the mount point to create.
defaultlocation
- Location in the file system the dialog should open with. Leave blank for system default.
callback
- Function to call when the user has selected a directory.
persistent
- Whether or not this mount point should be remounted if the application restarted. Optional. Defaults to false.
void browseForFile( <String> name, <String> defaultlocation, <Function> callback, <boolean> persistent, <boolean> multiple, <Array> filter )
Note that this method is not supported for Opera Unite applications.
Calling this function will open a file chooser dialog. When the user selects a file, the file is mounted and the given
callback
is called with a corresponding File
object. If the user cancels the dialog, or if mounting fails,
the callback is called with a null argument.
Mount points are by default destroyed whenever the application is closed. If you give the persistent
argument as true
, the mount point will be remounted the next time the application is started.
The appearance of the dialog can be manipulated with the various arguments to the method. The
defaultlocation
argument is used to specify the initial directory of the dialog. The
multiple
argument is used to control whether or not the user can select multiple files.
The filter
can be given an array of file types such as 'txt', which limits the types of the files the user
can select.
If the method is called with multiple
set to true
, a virtual directory will be created and
mounted with the given name, containing the selected files. The callback will be called with the File representing the
virtual directory. It is not possible to add further files to this mount point, although you can delete files already
in it.
This function will only be called as a result of direct user interaction, such as a click event or similar. If called from a timeout or a programatically dispatched event, it will be ignored by the runtime.
Mount points are mounted as read-write, so you should take care to protect your data by limiting users' access to it.
name
- The name of the mount point to create.
defaultlocation
- Location in the file system the dialog should open with. Leave blank for system default.
callback
- Function to call when the user selects a file in the dialog.
persistent
- Whether or not this mount point should be remounted if the application restarted. Optional. Defaults to false.
multiple
- Whether or not multiple files can be chosen in the dialog. Optional. Defaults to false.
filter
- Array of file type extensions to filter the list of selectable file types in the dialog. Defaults to '*'. Not implemented.
void browseForSave( <String> name, <String> defaultlocation, <Function> callback, <boolean> persistent )
Note that this method is not supported for Opera Unite applications.
Currently, the selected File is just returned, but not mounted. Consequently, using persistent
has no meaning.
Calling this function will open a file chooser dialog whose start location is the location of the given mount point.
In this dialog the user may create a new file. A File
object is created and mounted and the given callback is called with
the object. If the user cancels the dialog, or if mounting fails, the callback is called with a null
argument.
If the file already exists, a File representing it is sent in the callback. If it doesn't exist, a File
object
is returned with the exists
property set to false. It will be physically created only after it is
opened.
Mount points are by default destroyed whenever the application is closed. If you give the persistent
argument as true
, the mount point will be remounted the next time the application is started.
This function will only be called as a result of direct user interaction, such as a click event or similar. If called from a timeout or a programatically dispatched event, it will be ignored by the runtime.
Mount points are mounted as read-write, so you should take care to protect your data by limiting users' access to it.
name
- The name of the mount point to create.
defaultlocation
- Location in the file system the dialog should open with. Leave blank for system default.
callback
- Function to call when the user selects a file in the dialog.
persistent
- Whether or not this mount point should be remounted if the application restarted. Optional.
File mountSystemDirectory( <String> location, <String> name )
Applications that use the File I/O API have access to three special directories:
These directories of the application are not mounted by default. You need to call this
method to mount and use them. Once mounted, they are available through the
mountPoints
property like other mount points. Files and directories under them
can be accessed by resolving and using the mountpoint URL protocol as for normal
files.
The application directory is always mounted as readonly.
If you do not supply the name
argument, the location
argument is used as the name
of the mount point. They are then available as the mount points storage
,
application
and shared
, with paths /storage
, /application
and /shared
respectively.
Note that the shared
directory is mounted as read-write unless the underlying file system
defines it to be read-only. You should take care to protect your data by limiting access and
checking for exploitable code.
location
- Name of the system directory to mount, either storage
, application
or shared
.
name
- Name to mount the directory as. If not present, the location is used. Optional.
File
object representing the mounted system directory, or null if the location is invalid or if the system directory is not defined.
void removeMountPoint( <File> mountpoint )
File
object representing the mount point. If the mount point is mounted as persistent, removing it will also
remove the persistance.mountpoint
- File
object representing the mount point or a String with the name of the mount point.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |