Filesystem API

The Filesystem API provides access to a device's filesystem.

The filesystem is represented as an abstract collection of disjointed filesystem virtual
root locations, each corresponding to a specific location in the device
filesystem. The filesystem API exposes the hierarchies below these root
locations as a single virtual filesystem, but provides no access to other
parts of the device filesystem.

Each virtual root has a string name. Each file or directory within the virtual
filesystem is addressed using a fully-qualified path of the form:
<root name>/<path> where <rootname> is
the name of the virtual root and <path> is the path to the file or
directory relative to that root.

The following virtual roots must be supported:

images - the location for images

videos - the location for videos

music - the location for sounds

documents - the location for documents

downloads - the location for downloaded items

ringtones - the location for ringtones (read-only location)

camera - the location for the pictures and videos taken by a device (supported since Tizen 2.3)

wgt-package - the location for widget package which is read-only

wgt-private - the location for a widget's private storage

wgt-private-tmp - the location for a widget's private volatile storage

The file URI path is also supported. To access other paths out of virtual root, for example 'file:///tmp' can be used as location parameter.

To access specific locations apart from those specified above, a file handle must be retrieved using the filesystem.resolve() call.

A file handle represents either a file or a directory:

For a file, the isFile attribute is set to true.

For a directory, the isDirectory attribute is set to true.

A file can be opened for both read and write operations, using a
FileStream handle. A list of files and sub-directories can be obtained from a
directory and a resolve method exists to resolve files or sub-directories
more conveniently than processing directory listings.

The implementation must support the use of the following characters in file names:

Letters (a-z, A-Z)

Numbers (0-9)

Blank space

Underscore ("_")

Hyphen ("-")

Period (".")

The implementation may support additional characters in file names, depending on platform support.

The implementation may forbid the use of additional characters in file names, depending on the platform. The use of the path (component) separator "/" should not be allowed in file names.

Some other file name and path characteristics are platform-dependent,
for example, maximum path length, file name length, case sensitivity, additional
character support, etc. Therefore, it is recommended to avoid any dependency
on aspects that cannot be supported across multiple platforms.

When a path is used to interact with the underlying filesystem, the encoding used for the file path should be the platform default.

This manager interface exposes the Filesystem base API, and provides functionalities, such
as determining root and default locations, resolving a given location into a file handle, and registering filesystem listeners for filesystem events.

Methods

A location can contain a virtual path like 'documents/some_file.txt'
or a file URI like 'file:///my_strange_path/some_file.png'.
A location is not allowed to contain the "." or ".." substrings in its value.

The list of root locations that must be supported by a compliant implementation are:

documents - The default folder in which text documents (such as pdf, doc...) are stored by default in a device. For example, in some platforms it corresponds to the "My Documents" folder.

images - The default folder in which still images, like pictures (in formats including jpg, gif, png, etc.), are stored in the device by default. For example, in some platforms it corresponds to the "My Images" folder.

music - The default folder in which sound clips (in formats including mp3, aac, etc.) are stored in the device by default. For example, in some platforms it corresponds to the "My Music" folder.

videos - The default folder in which video clips (in formats including avi, mp4, etc.) are stored in the device by default. For example, in some platforms it corresponds to the "My Videos" folder.

downloads - The default folder in which downloaded files (from sources including browser, e-mail client, etc.) are stored by default in the device. For example, in some platforms it corresponds to the "Downloads" folder.

ringtones: The default folder in which ringtones (such as mp3, etc) are stored in the device.

camera : The default folder in which pictures and videos taken by a device are stored.

wgt-package - The read-only folder to which the content of a widget file is extracted.

wgt-private - The private folder in which a widget stores its information. This folder must be accessible only to the same widget and other widgets or applications must not be able to access the stored information.

wgt-private-tmp - Temporary, the private folder in which a widget can store data that is available during a widget execution cycle. Content of this folder can be removed from this directory when the widget is closed or the Web Runtime is restarted. This folder must be accessible only to the same widget and other widgets or applications must not be able to access it.

The mode parameter specifies whether the resulting File object has read-only access ("r" access), read and write access ("rw" access), append access ("a" access), or write access ("w" access) to the root location containing directory tree.
Permission for the requested access is obtained from the security framework. Once the resulting File object has access, access is inherited by any other File objects that are derived from this instance without any further reference to the security framework, as noted in descriptions of certain methods of File.

The ErrorCallback is launched with these error types:

InvalidValuesError - If any of the input parameters contain an invalid value.
For example, the mode is "w" for the read-only virtual roots (wgt-package and ringtones).

NotFoundError - If the location input argument does not correspond to a valid location.

UnknownError - If any other error occurs.

Privilege level:
public

Privilege:
http://tizen.org/privilege/filesystem.read

Remark : camera location is supported since Tizen 2.3. If a device does not support camera, NotSupportedError will be thrown.

Parameters:

location:
Location to resolve that can be a virtual path or file URI

onsuccess:
Callback method to be invoked when the location has been successfully resolved, passing the newly created File object

onerror [optional] [nullable]:
Callback method to be invoked when an error has occurred

mode [optional] [nullable]:
Optional value to indicate the file access mode on all files and directories that can be reached from the File object passed to onsuccess Default value of this parameter is rw if absent or null.

Exceptions:

WebAPIException

with error type TypeMismatchError, if any of the input parameter is not compatible with the expected type for that parameter.

with error type SecurityError, if the application does not have the privilege to call this method.

with error type NotSupportedError, if this feature is not supported (e.g. in the case of 'camera' virtual path if the device does not support camera)

Lists the available storages (both internal and external) on a device.
The onsuccess method receives a list of the data structures as input argument containing additional information about each drive found.
It gets storages which are labeled as 'internal0', labeled after virtual roots ('images', 'documents', etc.) and labeled with prefix 'removable_' (for external storages).

The most common usage for this method is to watch for any additions and removals of external storages.

When executed, it returns a subscription identifier that identifies the watch operation. After returning the identifier, the watch operation is started asynchronously. The onsuccess method will be invoked every time a storage state changes. If the attempt fails, the onerror if present will be invoked with the relevant error type.

The watch operation must continue until the removeStorageStateChangeListener() method is called with the corresponding subscription identifier.

Privilege level:
public

Privilege:
http://tizen.org/privilege/filesystem.write

Parameters:

onsuccess:
Callback method to be invoked when any change is made to storage state

onerror [optional] [nullable]:
Callback method to be invoked when an error occurs during the watch process

Return value:

long Subscription identifier

Exceptions:

WebAPIException

with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

with error type SecurityError, if the application does not have the privilege to call this method.

If the watchId argument is valid and corresponds to a subscription already in place, the watch process will be stopped and no further callbacks will be invoked.
Otherwise, the method call has no effect.

Privilege level:
public

Privilege:
http://tizen.org/privilege/filesystem.write

Parameters:

watchId:
Subscription identifier

Exceptions:

WebAPIException

with error type SecurityError, if the application does not have the privilege to call this method.

To retrieve the mount point, the resolve() method should be used using the label as argument.

Attributes

readonly
DOMString label

The storage name.

This attribute is used as an input for methods such as getStorage() and also used as location parameter for File.resolve() and FileSystemManager.resolve().

Since:
1.0

readonly
FileSystemStorageType type

The storage type as internal or external.

Since:
1.0

readonly
FileSystemStorageState state

The storage state as mounted or not.

Since:
1.0

2.4. File

The File interface represents the file abstraction in use.
A file handle represents a file if the isFile property is true,
and if the isFile property is false, the file handle represents a directory.
If a file handle represents a directory, it can address files and directories.

The file object permissions for the file object location and tree rooted
at that location depends upon the mode defined in the resolve method.
When a File object creates a child File object,
the new File object inherits its access rights from
the parent object without any reference to the security framework, as
noted in certain methods of File.

A file handle representing a file can be opened for I/O operations,
such as reading and writing.

A file handle representing a directory can be used for listing all
files and directories rooted as the file handle location.

This attribute represents the actual state of a file or directory in the filesystem. Its value is not affected by the mode used in FileSystemManager.resolve() that was used to create the File object from which this File object was obtained.

This timestamp is equivalent to the timestamp when a call to createFile() succeeds.

If the platform does not support this attribute, it will
be null.

It is unspecified and platform-dependent if the creation
timestamp changes when a file is moved.

Since:
1.0

readonly
Date modified [nullable]

The timestamp when the most recent modification is made to a file, usually when the last write operation succeeds.

Opening a file for reading does not change the modification timestamp.

If the platform does not support this attribute, it will be null.

It is unspecified and platform-dependent if the modified
timestamp changes when a file is moved.

Since:
1.0

Code example:

console.log(file.modified); /* Displays the modification timestamp */

readonly
DOMString path

The path of a file after excluding its file name.

It begins with the name of the root containing the file, followed by the path, including the directory containing the file, but excluding the file name.

Except in some special cases of the File representing the root itself, the last
character is always '/'.

For example, if a file is located at music/ramones/volume1/RockawayBeach.mp3,
the path is music/ramones/volume1/.

For example, if a directory is located at music/ramones/volume1, the path is
music/ramones/.

For the virtual roots, the path is same as the name of the virtual root.
For example, if the root is music, then the path is music. If the root is documents, then the path is documents.

Since:
1.0

Code example:

console.log(file.path); /* Must be 'music/' if the file is music/foo.mp3 */

readonly
DOMString name

The file name after excluding the root name and any path components.

This is the name of this file, excluding the root name and any other path components.

For example, if a file is located at
music/ramones/volume1/RockawayBeach.mp3, the name is 'RockawayBeach.mp3'.

For example, if a directory is located at music/ramones/volume1, the
name is be 'volume1'.

For the special case of the root itself, the name is an empty string.

Since:
1.0

Code example:

/* Must be foo.mp3 if the file path is music/foo.mp3 */
console.log(file.name);

readonly
DOMString fullPath

The full path of a file.

It begins with the name of the root containing the file,
and including the name of the file or directory itself.

For instance, if the RockawayBeach.mp3 file is located at music/ramones/volume1/, then the fullPath is music/ramones/volume1/RockawayBeach.mp3.

For a directory, if the volume1 directory is located at music/ramones/, then the fullPath is music/ramones/volume1.

For the special case of the root itself, if the root is music, then the fullPath is music.

The fullPath is always equal to path + name.

Since:
1.0

Code example:

/* Must be music/track1.mp3 if the file is music/track1.mp3 */
console.log(file.fullPath);

readonly
unsigned long long fileSize

The size of this file, in bytes.

If an attempt to read this attribute for a directory is made, undefined is returned. To retrieve the number of files and directories contained in the directory, use the length attribute.

Since:
1.0

Code example:

/* Displays the file size */
console.log(file.fileSize);

readonly
long length

The number of files and directories contained in a file handle.

If an attempt to read this attribute for a file is made, undefined is returned. To retrieve the size of a file, use the fileSize attribute.

Since:
1.0

Code example:

/* '3' if the directory contains two files and one sub-directory */
console.log(file.length);

Methods

toURI

Returns a URI for a file to identify an entry (such as using it as the src attribute on an HTML img element).
The URI has no specific expiration, it should be valid at least as long as the file exists.

DOMString toURI();

Since:
1.0

If that URI corresponds to any of the public virtual roots (that is
images, videos, music, documents, and downloads) the URI
must be globally unique and could be used by any widget.

If that URI corresponds to a file located in any a widget's private areas (such as wgt-package, wgt-private, wgt-private-tmp),
the generated URI must be unique for that file and for the widget making the request (such as including some derived from the widget ID in the URI).
These URIs must not be accessible to other widgets, apart from the one invoking this method.

Privilege level:
public

Privilege:
http://tizen.org/privilege/filesystem.read

Return value:

DOMString URI that identifies the file or null if an error occurs

Exceptions:

WebAPIException

with error type SecurityError, if the application does not have the privilege to call this method.

The list of files is passed as a File[] in onsuccess() and contains directories and files. However, the directories "." and ".." must not be returned. Each File object that is part of the array must inherit all the access rights (that is, one of the values in FileMode) from the File object in which this method is invoked.

If the filter is passed and contains valid values, only those directories and files in the directory that match the filter criteria specified in the FileFilter interface must be returned in the onsuccess() method. If no filter is passed, the filter is null or undefined, or the filter contains invalid values, the implementation must return the full list of files in the directory.

If the directory does not contain any files or directories, or the filter criteria does not matched with any files or directories, the onsuccess() is invoked with an empty array.

The ErrorCallback is launched with these error types:

IOError - If the operation is launched on a file (not a directory).

InvalidValuesError - If any of the input parameters contain an invalid value.

UnknownError - If any other error occurs.

Privilege level:
public

Privilege:
http://tizen.org/privilege/filesystem.read

Parameters:

onsuccess:
Callback method to be invoked when the list operation has been successfully completed

onerror [optional] [nullable]:
Callback method to be invoked when an error has occurred

filter [optional] [nullable]:
Criteria to restrict the listed files

Exceptions:

WebAPIException

with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.

with error type SecurityError, if the application does not have the privilege to call this method.

This operation is performed asynchronously. If the file is opened successfully, the onsuccess() method is invoked with a FileStream that can be used for reading and writing the file, depending on the mode. The returned FileStream instance includes a file pointer, which represents the current position in the file. The file pointer, by default, is at the start of the file, except in the case of opening a file in append ("a") mode, in which case the file pointer points to the end of the file.

The ErrorCallback is launched with these error types:

InvalidValuesError - If any of the input parameters contains an invalid value.

IOError - The operation is launched on a directory (not a file), the file is not valid or it does not exist.

UnknownError - If any other error occurs.

Privilege level:
public

Privilege:
http://tizen.org/privilege/filesystem.read

Parameters:

mode:
Mode in which the file is opened"r" for reading"a" for appending"w" for [over]writing"rw" for reading and writing

onsuccess:
Callback method to be invoked when a file has been opened

onerror [optional] [nullable]:
Callback method to be invoked when an error has occurred

encoding [optional] [nullable]:
Encoding to use for read/write operations on the file, at least the following encodings must be supported:"UTF-8" default encoding"ISO-8859-1" latin1 encodingIf no encoding is passed by the developer, then the default platform encoding must be used.

Exceptions:

WebAPIException

with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.

with error type SecurityError, if the application does not have the privilege to call this method.

If the operation is successfully executed, the onsuccess() method is invoked and a DOMString is passed as input parameter that represents the file content in the format determined by the encoding parameter.

The ErrorCallback is launched with these error types:

InvalidValuesError - If any of the input parameters contain an invalid value.

IOError - If the operation is launched on a directory (not a file), the file is not valid, or the file does not exist.

UnknownError - If any other error occurs.

Privilege level:
public

Privilege:
http://tizen.org/privilege/filesystem.read

Parameters:

onsuccess:
Callback method to be invoked when a file has been successfully read

onerror [optional] [nullable]:
Callback method to be invoked when an error occurs while reading a file

encoding [optional] [nullable]:
Encoding for read/write operations on a file, at least the following encodings must be supported:"UTF-8" default encoding"ISO-8859-1" latin1 encodingIf no encoding is passed by the developer, then the default platform encoding must be used.

Exceptions:

WebAPIException

with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.

with error type SecurityError, if the application does not have the privilege to call this method.

The copy of the file or directory identified by the originFilePath parameter must be created in the path passed in the destinationFilePath parameter.

The file or directory to copy must be under the Directory from which the method is invoked, otherwise the operation must not be performed.

If the copy is performed successfully, the onsuccess() method is invoked.

The ErrorCallback is launched with these error types:

InvalidValuesError - If any of the input parameters contain an invalid value.

NotFoundError - If the originFilePath does not correspond to a valid file or destinationPath is not a valid path.

IOError - If the file in which the copyTo() method is invoked is a file (and not a directory), originFilePath corresponds to a file or directory in use by another process, overwrite parameter is false and destinationFilePath corresponds to an existing file or directory.

UnknownError - If any other error occurs.

Privilege level:
public

Privilege:
http://tizen.org/privilege/filesystem.write

Parameters:

originFilePath:
Origin full virtual file or directory path and it must be under the current directory

destinationFilePath:
New full virtual file path or directory path

overwrite:
Attribute to determine whether overwriting is allowed or not If set to true, it enforces overwriting an existing file.

onsuccess [optional] [nullable]:
Callback method to be invoked when the file has been copied

onerror [optional] [nullable]:
Callback method to be invoked when an error has occurred

Exceptions:

WebAPIException

with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.

with error type SecurityError, if the application does not have the privilege to call this method.

Moves (and overwrites if possible and specified) a file or a directory from a specified location to another.
This operation is different from instantiating copyTo() and then deleting the original file, as on certain platforms, this operation does not require extra disk space.

The file or directory identified by the originFilePath parameter is moved to the path passed in the destinationFilePath parameter.

The file to move must be under the directory from which the method is invoked, else the operation can not be performed.

If the file or directory is moved successfully, the onsuccess() method is invoked.

The ErrorCallback is launched with these error types:

InvalidValuesError - If any of the input parameters contain an invalid value.

NotFoundError - If originFilePath does not correspond to a valid file or destinationPath is not a valid path.

IOError - If the File in which the moveTo() method is invoked is a file (not a directory), originFilePath corresponds to a file or directory in use by another process, overwrite parameter is false and destinationFilePath corresponds to an existing file or directory.

UnknownError - If any other error occurs.

Privilege level:
public

Privilege:
http://tizen.org/privilege/filesystem.write

Parameters:

originFilePath:
Origin full virtual file or directory path, and it must be under the current directory

destinationFilePath:
New full virtual file path or directory path

overwrite:
Flag indicating whether to overwrite an existing file.When set to true, the files can be overwritten.

onsuccess [optional] [nullable]:
Callback method to be invoked when the file has been moved

onerror [optional] [nullable]:
Callback method to be invoked when an error has occurred

Exceptions:

WebAPIException

with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.

with error type SecurityError, if the application does not have the privilege to call this method.

A new directory will be created relative to the current
directory that this operation is performed on. The implementation will attempt to
create all necessary sub-directories specified in the dirPath, as well. The use of "."
or ".." in path components is not supported.

This operation can only be performed on file handlers that represent a directory (that is, isDirectory == true).

If the directory is successfully created, it will be returned.

In case the directory cannot be created, an error must be thrown with the appropriate error type.

Privilege level:
public

Privilege:
http://tizen.org/privilege/filesystem.write

Parameters:

dirPath:
Relative directory path, and it only contains characters supported by the underlying filesystem

Return value:

File File handle of the new directory.
The new File object has "rw" access rights, as it inherits this from the File object on which the createDirectory() method is called.

Exceptions:

WebAPIException

with error type IOError, if the dirPath already exists, if the file in which the createDirectory() method is invoked is a file (and not a directory).

with error type InvalidValuesError, if the dirPath does not contain a valid path.

with error type TypeMismatchError, if the input parameter is not compatible with the expected type.

with error type SecurityError, if the application does not have the privilege to call this method.

This method attempts to asynchronously delete a directory or directory tree under the current directory.

If the recursive parameter is set to true, all the directories and files under the specified directory must be deleted. If the recursive parameter is set to false, the directory is only deleted if it is empty, otherwise an IOError error type will be passed in onerror().

If the deletion is performed successfully, the onsuccess() is invoked.

The ErrorCallback is launched with these error types:

InvalidValuesError - If any of the input parameters contain an invalid value.

NotFoundError -If the passed directory does not correspond to a valid directory.

IOError - If the File in which the delete method is invoked is a file (and not a directory), the directory is in use by another process or the directory is not empty and recursive argument is false.This code is also used if a recursive deletion partially fails and any data deleted so far cannot be recovered. This may occur due to the lack of filesystem permissions or if any directories or files are already opened by other processes.

UnknownError - If any other error occurs.

Privilege level:
public

Privilege:
http://tizen.org/privilege/filesystem.write

Parameters:

directoryPath:
Full virtual path to the directory to delete (must be under the current one)

recursive:
Flag indicating whether the deletion is recursive or not When set to true recursive deletion is allowed. Also, this function deletes
all data in all subdirectories and so needs to be used with caution.

onsuccess [optional] [nullable]:
Callback method to be invoked when a directory is successfully deleted

onerror [optional] [nullable]:
Callback method to be invoked when an error has occurred

Exceptions:

WebAPIException

with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.

with error type SecurityError, if the application does not have the privilege to call this method.

When this dictionary is passed in the listFiles() method, the result-set of the listFiles() method must only contain the file items entries that match the attribute values of the filter.

A file item only matches the FileFilter object if all the attributes of the file item match all the attribute values of the filter which are defined (that is, only matching values other than undefined or null). This is similar to an SQL "AND" operation.

An attribute of the file entry matches the FileFilter attribute value in accordance with the
following rules:

For FileFilter attributes of type DOMString, an entry matches this value only if its corresponding attribute is an exact match. If the filter contains U+0025 'PERCENT SIGN' it is interpreted as a wildcard character and '%' matches any string of any length, including no length. If wildcards are used, the behavior is similar to the LIKE condition in SQL. To specify that a 'PERCENT SIGN' character is to be considered literally instead of interpreting it as a wildcard, developers can escape it with the backslash character (\).
The matching is not case sensitive, such as "FOO" matches a "foo" or an "f%" filter.

For File entry attributes of type Date, attributes start and end are included to allow filtering of File entries between two supplied dates. If either or both of these attributes are specified, the following rules apply:A) If both start and end dates are specified (that is, other than null), a File entry matches the filter if its corresponding attribute is the same as either start or end or between the two supplied dates (that is, after start and before end).B) If only the start attribute contains a value (other than null), a File entry matches the filter if its corresponding attribute is later than or equal to the start one.C) If only the end date contains a value (other than null), a file matches the filter if its corresponding attribute is earlier than or equal to the end date.

Dictionary members

DOMString name

The File name attribute filter.

Files that have a name that corresponds with this attribute (either exactly or with the specified wildcards) match this filtering criteria.

Since:
1.0

Date startModified

The File modified attribute filter.

Files with modified date later than this attribute or equal to it match the filtering criteria.

Since:
1.0

Date endModified

The File modified attribute filter.

Files with modified date earlier than this attribute or equal to it match the filtering criteria.

Since:
1.0

Date startCreated

The File created attribute filter.

Files with created date later than this attribute or equal to it match the filtering criteria.

Since:
1.0

Date endCreated

The File created attribute filter.

Files with created date earlier than this attribute or equal to it match the filtering criteria.

Since:
1.0

2.6. FileStream

The FileStream interface represents a handle to a File opened for read and/or write operations.
Read and write operations are performed relative to a position attribute, which is a pointer that represents the current position in the file.

A series of read/write methods are available that permit both binary and text to be processed.

Once a file stream is closed, any operation attempt made on this stream results in a standard JavaScript error.

The read/write operations in this interface do not throw any security exceptions as the access rights are expected to be granted through the initial resolve() method or through the openStream() method of the File interface. Therefore, all actions performed on a successfully resolved File and FileStream are expected to succeed. This avoids successive asynchronous calls and may potentially increase application for a user.

Attributes

readonly
boolean eof

The flag indicating whether the current file pointer is at the end of the file.

If set to true, this attribute indicates that the file pointer is at the end of the file.

If set to false, this attribute indicates that the file pointer is not at the end of the file and so it is anywhere within the file.

Since:
1.0

Code example:

if (stream.eof)
{
/* File has been read completely */
}

long position

The flag indicating the stream position for reads/writes.

The stream position is an offset of bytes from the start of the file stream. When invoking an operation that reads or writes from the stream, the operation will take place from the byte defined by this position attribute. If the read or write operation is successful, the position of the stream is advanced by the number of bytes read or written. If the read/write operation is not successful, the position of the stream is unchanged.

Since:
1.0

Code example:

console.log(stream.position); /* Displays current stream position */
/*
Alters current stream position to the begin of the file,
like seek() in C
*/
stream.position = 0;

readonly
long bytesAvailable

The number of bytes that are available for reading from the stream.

The number of bytes available for reading is the maximum amount of bytes that can be read in the next read operation.
It corresponds to the number of bytes available after the file pointer denoted by the position attribute.

-1 if EOF is true.

Since:
1.0

Code example:

console.log(stream.bytesAvailable); /* Displays the available bytes to be read */

Reads the specified number of characters from the position of the file pointer in a FileStream and returns the characters as a string.
The resulting string length might be shorter than charCount if EOF is true.

DOMString read(long charCount);

Since:
1.0

Privilege level:
public

Privilege:
http://tizen.org/privilege/filesystem.read

Parameters:

charCount:
Number of characters being read

Return value:

DOMString Array of read characters as a string

Exceptions:

WebAPIException

with error type IOError, if a read error occurs, such as the bytes in the stream cannot be decoded with the encoding in use.

with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.

with error type InvalidValuesError, if any of the input parameters contain an invalid value.

with error type SecurityError, if the application does not have the privilege to call this method.

Code example:

var text = stream.read(file.fileSize);
stream.close();

readBytes

Reads the specified number of bytes from a FileStream.

octet[] readBytes(long byteCount);

Since:
1.0

Privilege level:
public

Privilege:
http://tizen.org/privilege/filesystem.read

Parameters:

byteCount:
Number of bytes to read

Return value:

octet[] Result of read bytes as a byte (or number) array

Exceptions:

WebAPIException

with error type IOError, if a read error occurs.

with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.

with error type InvalidValuesError, if any of the input parameters contain an invalid value.