Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0110E10A80 for ; Tue, 17 Dec 2013 20:32:08 +0000 (UTC) Received: (qmail 91305 invoked by uid 500); 17 Dec 2013 20:32:07 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 91283 invoked by uid 500); 17 Dec 2013 20:32:07 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 91276 invoked by uid 99); 17 Dec 2013 20:32:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Dec 2013 20:32:07 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Dec 2013 20:32:03 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 19B272388C1C; Tue, 17 Dec 2013 20:31:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1551686 [4/19] - in /cordova/site/public/docs/en: 3.3.0/ edge/ Date: Tue, 17 Dec 2013 20:31:37 -0000 To: commits@cordova.apache.org From: mwbrooks@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131217203143.19B272388C1C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: cordova/site/public/docs/en/3.3.0/cordova_file_file.md.html URL: http://svn.apache.org/viewvc/cordova/site/public/docs/en/3.3.0/cordova_file_file.md.html?rev=1551686&r1=1551685&r2=1551686&view=diff ============================================================================== --- cordova/site/public/docs/en/3.3.0/cordova_file_file.md.html (original) +++ cordova/site/public/docs/en/3.3.0/cordova_file_file.md.html Tue Dec 17 20:31:35 2013 @@ -17,16 +17,18 @@ specific language governing permissions and limitations under the License. --> - - - - -Apache Cordova API Documentation - - - - - + + + + + + Apache Cordova API Documentation + + + + + +

File

@@ -264,9 +267,7 @@ File System Quick Example

An API to read, write and navigate file system hierarchies, based on the w3c file api.

-

-Objects -

+

Objects

-

-Accessing the Feature -

+ +

Accessing the Feature

As of version 3.0, Cordova implements device-level APIs as plugins. Use the CLI's plugin command, described in The Command-Line @@ -383,17 +383,17 @@ platform-specific configuration settings +

Some platforms may support this feature without requiring any special configuration. See Platform Support for an overview.


+

File

This object contains attributes of a single file.

-

-Properties -

+

Properties

  • name: The name of the file. (DOMString)

  • @@ -402,25 +402,21 @@ configuration. See Methods - + +

    Methods

    • slice: Select only a portion of the file to be read.
    -

    -Details -

    + +

    Details

    The File object contains attributes of a single file. You can get an instance of a File object by calling a FileEntry object's file() method.

    -

    -Supported Platforms -

    +

    Supported Platforms

    • Amazon Fire OS
    • @@ -430,9 +426,8 @@ an instance of a slice - + +

      slice

      Return a new File object, for which FileReader returns only the specified portion of the file. Negative values for start or end @@ -445,6 +440,7 @@ relative to the current slice. (See the

    • start: The index of the first byte to read, inclusive.

    • end: The index of the byte after the last one to read.

    +

    Quick Example

    var slicedFile = file.slice(10, 30);
    @@ -465,14 +461,14 @@ var slice3 = file.slice(120, 135);
     
  • Android
  • iOS
+
+

FileReader

The FileReader allows basic access to a file.

-

-Properties -

+

Properties

  • readyState: One of the reader's three possible states, either EMPTY, LOADING or DONE.

  • @@ -484,6 +480,7 @@ var slice3 = file.slice(120, 135);
  • onerror: Called when the read has failed. (Function)

  • onloadend: Called when the request has completed (either in success or failure). (Function)

+

NOTE: The following porperty is not supported:

    @@ -491,9 +488,8 @@ var slice3 = file.slice(120, 135); onprogress: Called while reading the file, reporting progress in terms of progress.loaded/progress.total. (Function)
-

-Methods -

+ +

Methods

  • abort: Aborts reading file.

  • @@ -502,18 +498,15 @@ var slice3 = file.slice(120, 135);
  • readAsBinaryString: Reads file as binary and returns a binary string.

  • readAsArrayBuffer: Reads file as an ArrayBuffer.

-

-Details -

+ +

Details

The FileReader object offers a way to read files from the device's file system. Files can be read as text or as a base64 data-encoded string. Event listeners receive the loadstart, progress, load, loadend, error, and abort events.

-

-Supported Platforms -

+

Supported Platforms

  • Amazon Fire OS
  • @@ -523,9 +516,8 @@ string. Event listeners receive the Windows Phone 7 and 8
  • Windows 8
-

-readAsDataURL -

+ +

readAsDataURL

Parameters:

@@ -533,9 +525,8 @@ string. Event listeners receive the file: the file object to read. -

-Quick Example -

+ +

Quick Example

function win(file) {
     var reader = new FileReader();
@@ -553,9 +544,7 @@ var fail = function (error) {
 entry.file(win, fail);
 
-

-readAsText -

+

readAsText

Parameters:

@@ -563,9 +552,8 @@ entry.file(win, fail);
  • file: the file object to read.

  • encoding: the encoding to use to encode the file's content. Default is UTF8.

  • -

    -Quick Example -

    + +

    Quick Example

    function win(file) {
         var reader = new FileReader();
    @@ -583,9 +571,7 @@ var fail = function (error) {
     entry.file(win, fail);
     
    -

    -abort -

    +

    abort

    function win(file) {
         var reader = new FileReader();
    @@ -604,9 +590,7 @@ function fail(error) {
     entry.file(win, fail);
     
    -

    -Full Example -

    +

    Full Example

    <!DOCTYPE html>
     <html>
    @@ -670,16 +654,13 @@ entry.file(win, fail);
     </html>
     
    -

    -iOS Quirks -

    +

    iOS Quirks

    • The encoding parameter is not supported, and UTF8 encoding is always in effect.
    -

    -readAsBinaryString -

    + +

    readAsBinaryString

    Currently supported on iOS and Android only.

    @@ -689,9 +670,8 @@ entry.file(win, fail);
  • file: the file object to read.
  • -

    -Quick Example -

    + +

    Quick Example

    function win(file) {
         var reader = new FileReader();
    @@ -709,9 +689,7 @@ var fail = function (error) {
     entry.file(win, fail);
     
    -

    -readAsArrayBuffer -

    +

    readAsArrayBuffer

    Currently supported on iOS and Android only.

    @@ -721,9 +699,8 @@ entry.file(win, fail);
  • file: the file object to read.
  • -

    -Quick Example -

    + +

    Quick Example

    function win(file) {
         var reader = new FileReader();
    @@ -742,13 +719,12 @@ entry.file(win, fail);
     

    +

    FileWriter

    As object that allows you to create and write data to a file.

    -

    -Properties -

    +

    Properties

    • readyState: One of the three possible states, either INIT, WRITING, or DONE.

    • @@ -762,6 +738,7 @@ entry.file(win, fail);
    • onerror: Called when the write has failed. (Function)

    • onwriteend: Called when the request has completed (either in success or failure). (Function)

    +

    The following property is not supported:

      @@ -775,9 +752,8 @@ entry.file(win, fail);
    • truncate: Shortens the file to the specified length.

    • write: Writes data to the file.

    -

    -Details -

    + +

    Details

    The FileWriter object offers a way to write UTF-8 encoded files to the device file system. Applications respond to writestart, @@ -793,9 +769,7 @@ write to the end of the file.

    Text data is supported by all platforms listed below. Text is encoded as UTF-8 before being written to the filesystem. Some platforms also support binary data, which can be passed in as either an ArrayBuffer or a Blob.

    -

    -Supported Platforms -

    +

    Supported Platforms

    Text and Binary Support:

    @@ -804,6 +778,7 @@ write to the end of the file.

  • Android
  • iOS
  • +

    Text-only Support:

      @@ -811,9 +786,8 @@ write to the end of the file.

    • Windows Phone 7 and 8
    • Windows 8
    -

    -Seek Quick Example -

    + +

    Seek Quick Example

    function win(writer) {
         // fast forwards file pointer to end of file
    @@ -827,9 +801,7 @@ var fail = function(evt) {
     entry.createWriter(win, fail);
     
    -

    -Truncate Quick Example -

    +

    Truncate Quick Example

    function win(writer) {
         writer.truncate(10);
    @@ -842,9 +814,7 @@ var fail = function(evt) {
     entry.createWriter(win, fail);
     
    -

    -Write Quick Example -

    +

    Write Quick Example

    function win(writer) {
         writer.onwrite = function(evt) {
    @@ -860,9 +830,7 @@ var fail = function(evt) {
     entry.createWriter(win, fail);
     
    -

    -Binary Write Quick Example -

    +

    Binary Write Quick Example

    function win(writer) {
         var data = new ArrayBuffer(5),
    @@ -883,9 +851,7 @@ var fail = function(evt) {
     entry.createWriter(win, fail);
     
    -

    -Append Quick Example -

    +

    Append Quick Example

    function win(writer) {
         writer.onwrite = function(evt) {
    @@ -902,9 +868,7 @@ var fail = function(evt) {
     entry.createWriter(win, fail);
     
    -

    -Abort Quick Example -

    +

    Abort Quick Example

    function win(writer) {
         writer.onwrite = function(evt) {
    @@ -921,9 +885,7 @@ var fail = function(evt) {
     entry.createWriter(win, fail);
     
    -

    -Full Example -

    +

    Full Example

    <!DOCTYPE html>
     <html>
    @@ -981,30 +943,26 @@ entry.createWriter(win, fail);
     

    +

    FileSystem

    This object represents a file system.

    -

    -Properties -

    +

    Properties

    • name: The name of the file system. (DOMString)

    • root: The root directory of the file system. (DirectoryEntry)

    -

    -Details -

    + +

    Details

    The FileSystem object represents information about the file system. The name of the file system is unique across the list of exposed file systems. The root property contains a DirectoryEntry object that represents the file system's root directory.

    -

    -Supported Platforms -

    +

    Supported Platforms

    • Amazon Fire OS
    • @@ -1014,10 +972,9 @@ that represents the file system's root d
    • Windows Phone 7 and 8
    • Windows 8
    -

    - -File System Quick Example -

    + +

    +File System Quick Example

    function onSuccess(fileSystem) {
         console.log(fileSystem.name);
    @@ -1028,9 +985,7 @@ File System Quick Example
     window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onSuccess, null);
     
    -

    -Full Example -

    +

    Full Example

    <!DOCTYPE html>
     <html>
    @@ -1069,15 +1024,14 @@ window.FileEntry
     
     

    Represents a file on a file system, as defined in the W3C Directories and Systems specification.

    -

    -Properties -

    +

    Properties

    • isFile: Always true. (boolean)

    • @@ -1085,6 +1039,7 @@ specification.

    • name: The name of the FileEntry, excluding the path leading to it. (DOMString)

    • fullPath: The full absolute path from the root to the FileEntry. (DOMString)

    +

    NOTE: The following attribute is defined by the W3C specification, but is not supported:

    @@ -1093,9 +1048,8 @@ but is not supported:

    filesystem: The file system on which the FileEntry resides. (FileSystem) -

    -Methods -

    + +

    Methods

    • getMetadata: Look up metadata about a file.

    • @@ -1108,9 +1062,8 @@ but is not supported:

    • createWriter: Creates a FileWriter object that can be used to write to a file.

    • file: Creates a File object containing file properties.

    -

    -Supported Platforms -

    + +

    Supported Platforms

    • Amazon Fire OS
    • @@ -1120,9 +1073,8 @@ but is not supported:

    • Windows Phone 7 and 8
    • Windows 8
    -

    -getMetadata -

    + +

    getMetadata

    Look up metadata about a file.

    @@ -1132,6 +1084,7 @@ but is not supported:

  • successCallback: A callback that is passed a Metadata object. (Function)

  • errorCallback: A callback that executes if an error occurs when retrieving the Metadata. Invoked with a FileError object. (Function)

  • +

    Quick Example

    function success(metadata) {
    @@ -1146,9 +1099,7 @@ function fail(error) {
     entry.getMetadata(success, fail);
     
    -

    -setMetadata -

    +

    setMetadata

    Set metadata on a file.

    @@ -1157,6 +1108,7 @@ entry.getMetadata(success, fail);
    • This sets the extended attributes of a file.
    +

    Parameters:

      @@ -1164,6 +1116,7 @@ entry.getMetadata(success, fail);
    • errorCallback: A callback that executes when the metadata is not successfully set. (Function)

    • metadataObject: An object that contains the metadata's keys and values. (Object)

    +

    Quick Example

    function success() {
    @@ -1183,6 +1136,7 @@ entry.setMetadata(success, fail, { "com.
     
    • Only the com.apple.MobileBackup extended attribute is supported. Set the value to 1 to prevent the file from being backed up to iCloud. Set the value to 0 to re-enable the file to be backed up to iCloud.
    +

    Quick Example

    function setFileMetadata(localFileSystem, filePath, metadataKey, metadataValue)
    @@ -1217,9 +1171,7 @@ entry.setMetadata(success, fail, { "com.
         setFileMetadata(LocalFileSystem.PERSISTENT, "Backups/sqlite.db", "com.apple.MobileBackup", 1);
     
    -

    -moveTo -

    +

    moveTo

    Move a file to a different location on the file system. An error results if the app attempts to:

    @@ -1228,6 +1180,7 @@ results if the app attempts to:

  • move a file into its parent if a name different from its current one isn't provided;

  • move a file to a path occupied by a directory;

  • +

    In addition, moving a file on top of an existing file attempts to delete and replace that file.

    @@ -1239,6 +1192,7 @@ delete and replace that file.

  • successCallback: A callback that is passed the new file's FileEntry object. (Function)

  • errorCallback: A callback that executes if an error occurs when attempting to move the file. Invoked with a FileError object. (Function)

  • +

    Quick Example

    function success(entry) {
    @@ -1259,9 +1213,7 @@ function moveFile(entry) {
     }
     
    -

    -copyTo -

    +

    copyTo

    Copy a file to a new location on the file system. An error results if the app attempts to:

    @@ -1269,6 +1221,7 @@ the app attempts to:

    • copy a file into its parent if a name different from its current one is not provided.
    +

    Parameters:

      @@ -1277,6 +1230,7 @@ the app attempts to:

    • successCallback: A callback that is passed the new file's FileEntry object. (Function)

    • errorCallback: A callback that executes if an error occurs when attempting to copy the file. Invoked with a FileError object. (Function)

    +

    Quick Example

    function win(entry) {
    @@ -1297,9 +1251,7 @@ function copyFile(entry) {
     }
     
    -

    -toURL -

    +

    toURL

    Returns a URL that can be used to locate the file.

    @@ -1310,9 +1262,7 @@ var fileURL = entry.toURL(); console.log(fileURL);
    -

    -remove -

    +

    remove

    Deletes a file.

    @@ -1322,6 +1272,7 @@ console.log(fileURL);
  • successCallback: A callback that executes after the file has been deleted. Invoked with no parameters. (Function)

  • errorCallback: A callback that executes if an error occurs when attempting to delete the file. Invoked with a FileError object. (Function)

  • +

    Quick Example

    function success(entry) {
    @@ -1336,9 +1287,7 @@ function fail(error) {
     entry.remove(success, fail);
     
    -

    -getParent -

    +

    getParent

    Look up the parent DirectoryEntry containing the file.

    @@ -1348,6 +1297,7 @@ entry.remove(success, fail);
  • successCallback: A callback that is passed the file's parent DirectoryEntry. (Function)

  • errorCallback: A callback that executes if an error occurs when attempting to retrieve the parent DirectoryEntry. Invoked with a FileError object. (Function)

  • +

    Quick Example

    function success(parent) {
    @@ -1362,9 +1312,7 @@ function fail(error) {
     entry.getParent(success, fail);
     
    -

    -createWriter -

    +

    createWriter

    Create a FileWriter object associated with the file represented by the FileEntry.

    @@ -1374,6 +1322,7 @@ entry.getParent(success, fail);
  • successCallback: A callback that is passed a FileWriter object. (Function)

  • errorCallback: A callback that executes if an error occurs while attempting to create the FileWriter. Invoked with a FileError object. (Function)

  • +

    Quick Example

    function success(writer) {
    @@ -1388,9 +1337,7 @@ function fail(error) {
     entry.createWriter(success, fail);
     
    -

    -file -

    +

    file

    Return a File object that represents the current state of the file that this FileEntry represents.

    @@ -1401,6 +1348,7 @@ that this File object. (Function)

  • errorCallback: A callback that executes if an error occurs when creating the File object, such as when the file no longer exists. Invoked with a FileError object. (Function)

  • +

    Quick Example

    function success(file) {
    @@ -1416,15 +1364,14 @@ entry.file(success, fail);
     

    +

    DirectoryEntry

    This object represents a directory on a file system, as defined by the W3C Directories and Systems specification.

    -

    -Properties -

    +

    Properties

    • isFile: Always false. (boolean)

    • @@ -1432,6 +1379,7 @@ specification.

    • name: The name of the DirectoryEntry, excluding the path leading to it. (DOMString)

    • fullPath: The full absolute path from the root to the DirectoryEntry. (DOMString)

    +

    NOTE: The following attribute is defined by the W3C specification, but is not supported:

    @@ -1440,9 +1388,8 @@ but is not supported:

    filesystem: The file system on which the DirectoryEntry resides. (FileSystem) -

    -Methods -

    + +

    Methods

    The following methods can be invoked on a DirectoryEntry object:

    @@ -1459,9 +1406,8 @@ but is not supported:

  • getFile: Create or look up a file.

  • removeRecursively: Delete a directory and all of its contents.

  • -

    -Supported Platforms -

    + +

    Supported Platforms

    • Amazon Fire OS
    • @@ -1471,9 +1417,8 @@ but is not supported:

    • Windows Phone 7 and 8
    • Windows 8
    -

    -getMetadata -

    + +

    getMetadata

    Look up metadata about a directory.

    @@ -1483,6 +1428,7 @@ but is not supported:

  • successCallback: A callback function to execute with a Metadata object. (Function)

  • errorCallback: A callback function to execute if an error occurs when retrieving the Metadata. Invoked with a FileError object. (Function)

  • +

    Quick Example

    function success(metadata) {
    @@ -1497,9 +1443,7 @@ function fail(error) {
     entry.getMetadata(success, fail);
     
    -

    -setMetadata -

    +

    setMetadata

    Sets a directory's extended attributes, or metadata. Currently works only on iOS.

    @@ -1511,6 +1455,7 @@ only on iOS.

  • errorCallback: A callback that executes when the metadata fails to be set. (Function)

  • metadataObject: An object that contains the metadata's keys and values. (Object)

  • +

    Quick Example

    function success() {
    @@ -1530,6 +1475,7 @@ entry.setMetadata(success, fail, { "com.
     
    • Only the com.apple.MobileBackup extended attribute is supported. Set the value to 1 to prevent the directory from being backed up to iCloud. Set the value to 0 to re-enable the directory to be backed up to iCloud.
    +

    Quick Example

    function setFolderMetadata(localFileSystem, subFolder, metadataKey, metadataValue)
    @@ -1564,9 +1510,7 @@ entry.setMetadata(success, fail, { "com.
         setFolderMetadata(LocalFileSystem.PERSISTENT, "Backups", "com.apple.MobileBackup", 1);
     
    -

    -moveTo -

    +

    moveTo

    Move a directory to a different location on the file system. An error results if the app attempts to:

    @@ -1576,6 +1520,7 @@ entry.setMetadata(success, fail, { "com.
  • move a directory to a path occupied by a file.

  • move a directory to a path occupied by a directory that is not empty.

  • +

    Moving a directory on top of an existing empty directory attempts to delete and replace that directory.

    @@ -1587,6 +1532,7 @@ delete and replace that directory.

  • successCallback: A callback that executes with the DirectoryEntry object for the new directory. (Function)

  • errorCallback: A callback that executes if an error occurs when attempting to move the directory. Invoked with a FileError object. (Function)

  • +

    Quick Example

    function success(entry) {
    @@ -1608,9 +1554,7 @@ function moveDir(entry) {
     }
     
    -

    -copyTo -

    +

    copyTo

    Copy a directory to a different location on the file system. An error results if the app attempts to:

    @@ -1618,6 +1562,7 @@ function moveDir(entry) {
  • copy a directory inside itself at any depth.

  • copy a directory into its parent if a name different from its current directory is not provided.

  • +

    Directory copies are always recursive, and copy all contents of the directory.

    Parameters:

    @@ -1628,6 +1573,7 @@ function moveDir(entry) {
  • successCallback: A callback that executes with the DirectoryEntry object for the new directory. (Function)

  • errorCallback: A callback that executes if an error occurs when attempting to copy the underlying directory. Invoked with a FileError object. (Function)

  • +

    Quick Example

    function win(entry) {
    @@ -1649,9 +1595,7 @@ function copyDir(entry) {
     }
     
    -

    -toURL -

    +

    toURL

    Returns a URL that can be used to locate the directory.

    @@ -1662,9 +1606,7 @@ var dirURL = entry.toURL(); console.log(dirURL);
    -

    -remove -

    +

    remove

    Deletes a directory. An error results if the app attempts to:

    @@ -1672,12 +1614,14 @@ console.log(dirURL);
  • delete a directory that is not empty.

  • delete the root directory of a filesystem.

  • +

    Parameters:

    • successCallback: A callback that executes after the directory is deleted. Invoked with no parameters. (Function)

    • errorCallback: A callback that executes if an error occurs when attempting to delete the directory. Invoked with a FileError object. (Function)

    +

    Quick Example

    function success(entry) {
    @@ -1692,9 +1636,7 @@ function fail(error) {
     entry.remove(success, fail);
     
    -

    -getParent -

    +

    getParent

    Look up the parent DirectoryEntry containing the directory.

    @@ -1704,6 +1646,7 @@ entry.remove(success, fail);
  • successCallback: A callback that is passed the directory's parent DirectoryEntry. (Function)

  • errorCallback: A callback that executes if an error occurs when attempting to retrieve the parent DirectoryEntry. Invoked with a FileError object. (Function)

  • +

    Quick Example

    function success(parent) {
    @@ -1718,9 +1661,7 @@ function fail(error) {
     entry.getParent(success, fail);
     
    -

    -createReader -

    +

    createReader

    Creates a new DirectoryReader to read entries in a directory.

    @@ -1730,15 +1671,14 @@ entry.getParent(success, fail); var directoryReader = entry.createReader();
    -

    -getDirectory -

    +

    getDirectory

    Creates or looks up an existing directory. An error results if the app attempts to:

    • create a directory whose immediate parent does not yet exist.
    +

    Parameters:

      @@ -1747,6 +1687,7 @@ var directoryReader = entry.createReader
    • successCallback: A callback that executes with a DirectoryEntry object. (Function)

    • errorCallback: A callback that executes if an error occurs when creating or looking up the directory. Invoked with a FileError object. (Function)

    +

    Quick Example

    function success(dirEntry) {
    @@ -1761,15 +1702,14 @@ function fail(error) {
     entry.getDirectory("newDir", {create: true, exclusive: false}, success, fail);
     
    -

    -getFile -

    +

    getFile

    Creates or looks up a file. An error results if the app attempts to:

    • create a file whose immediate parent does not yet exist.
    +

    Parameters:

      @@ -1778,6 +1718,7 @@ entry.getDirectory("newDir", {create: tr
    • successCallback: A callback that is passed a FileEntry object. (Function)

    • errorCallback: A callback that executes if an error occurs when creating or looking up the file. Invoked with a FileError object. (Function)

    +

    Quick Example

    function success(fileEntry) {
    @@ -1792,9 +1733,7 @@ function fail(error) {
     entry.getFile("newFile.txt", {create: true, exclusive: false}, success, fail);
     
    -

    -removeRecursively -

    +

    removeRecursively

    Deletes a directory and all of its contents. In the event of an error (such as trying to delete a directory containing a file that can't be removed), some of the contents of the directory may @@ -1803,12 +1742,14 @@ be deleted. An error results if the ap

    • delete the root directory of a filesystem.
    +

    Parameters:

    • successCallback: A callback that executes after the DirectoryEntry has been deleted. Invoked with no parameters. (Function)

    • errorCallback: A callback that executes if an error occurs when attempting to delete the DirectoryEntry. Invoked with a FileError object. (Function)

    +

    Quick Example

    function success(parent) {
    @@ -1823,15 +1764,14 @@ function fail(error) {
     entry.removeRecursively(success, fail);
     
    -

    -BlackBerry Quirks -

    +

    BlackBerry Quirks

    May fail with a ControlledAccessException in the following cases:

    • An app attempts to access a directory created by a previous installation of the app.
    +

    Solution: ensure temporary directories are cleaned manually, or by the application prior to reinstallation.

    @@ -1839,11 +1779,13 @@ entry.removeRecursively(success, fail);
    • If the device is connected by USB.
    +

    Solution: disconnect the USB cable from the device and run again.


    +

    DirectoryReader

    An object that lists files and directories within a directory, as @@ -1851,17 +1793,14 @@ defined in the W3C Directories and Systems specification.

    -

    -Methods -

    +

    Methods

    • readEntries: Read the entries in a directory.
    -

    -Supported Platforms -

    + +

    Supported Platforms

    • Amazon Fire OS
    • @@ -1871,9 +1810,8 @@ specification.

    • Windows Phone 7 and 8
    • Windows 8
    -

    -readEntries -

    + +

    readEntries

    Read the entries in this directory.

    @@ -1883,6 +1821,7 @@ specification.

  • successCallback: A callback that is passed an array of FileEntry and DirectoryEntry objects. (Function)

  • errorCallback: A callback that executes if an error occurs when retrieving the directory listing. Invoked with a FileError object. (Function)

  • +

    Quick Example

    function success(entries) {
    @@ -1904,32 +1843,29 @@ directoryReader.readEntries(success,fail
     

    +

    FileTransfer

    The FileTransfer object allows you to upload or download files to and from a server.

    -

    -Properties -

    +

    Properties

    • onprogress: Called with a ProgressEvent whenever a new chunk of data is transferred. (Function)
    -

    -Methods -

    + +

    Methods

    • upload: sends a file to a server.

    • download: downloads a file from server.

    • abort: Aborts an in-progress transfer.

    -

    -Details -

    + +

    Details

    The FileTransfer object provides a way to upload files to a remote server using an HTTP multi-part POST request. Both HTTP and HTTPS @@ -1941,9 +1877,7 @@ passed to the error callback. It is als Android) to download a file from a remote server and save it on the device.

    -

    -Supported Platforms -

    +

    Supported Platforms

    • Amazon Fire OS
    • @@ -1953,9 +1887,8 @@ device.

    • Windows Phone 7 and 8
    • Windows 8
    -

    -upload -

    + +

    upload

    Parameters:

    @@ -1967,6 +1900,7 @@ device.

  • options: Optional parameters such as file name and mimetype.

  • trustAllHosts: Optional parameter, defaults to false. If set to true, it accepts all security certificates. This is useful since Android rejects self-signed security certificates. Not recommended for production use. Supported on Android and iOS. (boolean)

  • +

    Quick Example

    // !! Assumes variable fileURI contains a valid URI to a text file on the device
    @@ -2100,9 +2034,7 @@ ft.upload(fileURI, uri, win, fail, optio
     

    Set the chunkedMode option to false to prevent problems uploading to a Nginx server.

    -

    -download -

    +

    download

    Parameters:

    @@ -2114,6 +2046,7 @@ to a Nginx server.

  • trustAllHosts: Optional parameter, defaults to false. If set to true, it accepts all security certificates. This is useful because Android rejects self-signed security certificates. Not recommended for production use. Supported on Android and iOS. (boolean)

  • options: Optional parameters, currently only supports headers (such as Authorization (Basic Authentication), etc).

  • +

    Quick Example

    // !! Assumes filePath is a valid path on the device
    @@ -2141,9 +2074,7 @@ fileTransfer.download(
     );
     
    -

    -abort -

    +

    abort

    Aborts an in-progress transfer. The onerror callback is passed a FileTransferError object which has an error code of FileTransferError.ABORT_ERR.

    @@ -2154,6 +2085,7 @@ fileTransfer.download(
  • Android
  • iOS
  • +

    Quick Example

    // !! Assumes variable fileURI contains a valid URI to a text file on the device
    @@ -2179,9 +2111,7 @@ ft.upload(fileURI, encodeURI("http://som
     ft.abort();
     
    -

    -onprogress -

    +

    onprogress

    Called with a ProgressEvent whenever a new chunk of data is transferred.

    @@ -2192,6 +2122,7 @@ ft.abort();
  • Android
  • iOS
  • +

    Example

    fileTransfer.onprogress = function(progressEvent) {
    @@ -2208,15 +2139,14 @@ fileTransfer.download(...); // or fileTr
     - On both Android an iOS, lengthComputable is false for downloads that use gzip encoding.


    +

    FileUploadOptions

    A FileUploadOptions object can be passed to the FileTransfer object's upload() method to specify additional parameters to the upload script.

    -

    -Properties -

    +

    Properties

    • fileKey: The name of the form element. Defaults to file. (DOMString)

    • @@ -2226,69 +2156,62 @@ upload script.

    • chunkedMode: Whether to upload the data in chunked streaming mode. Defaults to true. (Boolean)

    • headers: A map of header name/header values. Use an array to specify more than one value. (Object)

    -

    -Description -

    + +

    Description

    A FileUploadOptions object can be passed to the FileTransfer object's upload() method to specify additional parameters to the upload script.

    -

    -WP7 Quirk -

    +

    WP7 Quirk

    • chunkedMode: Ignored on WP7.
    +
    +

    FileUploadResult

    A FileUploadResult object is passed to the success callback of the FileTransfer object's upload() method.

    -

    -Properties -

    +

    Properties

    • bytesSent: The number of bytes sent to the server as part of the upload. (long)

    • responseCode: The HTTP response code returned by the server. (long)

    • response: The HTTP response returned by the server. (DOMString)

    -

    -Description -

    + +

    Description

    The FileUploadResult object is returned via the success callback of the FileTransfer object's upload() method.

    -

    -iOS Quirks -

    +

    iOS Quirks

    • Does not support responseCode or bytesSent.
    +
    +

    Flags

    Supplies arguments to the DirectoryEntry object's getFile() and getDirectory() methods, which look up or create files and directories, respectively.

    -

    -Properties -

    +

    Properties

    • create: Indicates that the file or directory should be created if it does not already exist. (boolean)

    • exclusive: Has has no effect by itself, but when used with create causes the file or directory creation to fail if the target path already exists. (boolean)

    -

    -Supported Platforms -

    + +

    Supported Platforms

    • Amazon Fire OS
    • @@ -2298,9 +2221,8 @@ directories, respectively.

    • Windows Phone 7 and 8
    • Windows 8
    -

    -Quick Example -

    + +

    Quick Example

    // Get the data directory, creating it if it doesn't exist.
     dataDir = fileSystem.root.getDirectory("data", {create: true});
    @@ -2310,35 +2232,30 @@ lockFile = dataDir.getFile("lockfile.txt
     

    +

    LocalFileSystem

    This object provides a way to obtain root file systems.

    -

    -Methods -

    +

    Methods

    -

    -Constants -

    + +

    Constants

    • LocalFileSystem.PERSISTENT: Used for storage that should not be removed by the user agent without application or user permission.

    • LocalFileSystem.TEMPORARY: Used for storage with no guarantee of persistence.

    -

    -Details -

    + +

    Details

    The LocalFileSystem object methods are defined on the window object.

    -

    -Supported Platforms -

    +

    Supported Platforms

    • Amazon Fire OS
    • @@ -2348,9 +2265,8 @@ lockFile = dataDir.getFile("lockfile.txt
    • Windows Phone 7 and 8
    • Windows 8
    -

    -Request File System Quick Example -

    + +

    Request File System Quick Example

    function onSuccess(fileSystem) {
         console.log(fileSystem.name);
    @@ -2360,9 +2276,7 @@ lockFile = dataDir.getFile("lockfile.txt
     window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onSuccess, onError);
     
    -

    -Resolve Local File System URI Quick Example -

    +

    Resolve Local File System URI Quick Example

    function onSuccess(fileEntry) {
         console.log(fileEntry.name);
    @@ -2371,9 +2285,7 @@ window.
    -

    -Full Example -

    +

    Full Example

    <!DOCTYPE html>
     <html>
    @@ -2436,9 +2348,8 @@ window.resolveLocalFileSystemURI("file:/
     
  • errorCallback: invoked if error occurs retrieving file system
  • -

    -Request File System Quick Example -

    + +

    Request File System Quick Example

    function onSuccess(fileSystem) {
         console.log(fileSystem.name);
    @@ -2449,30 +2360,26 @@ window.Metadata
     
     

    An interface that supplies information about the state of a file or directory.

    -

    -Properties -

    +

    Properties

    • modificationTime: The time when the file or directory was last modified. (Date)
    -

    -Details -

    + +

    Details

    The Metadata object represents information about the state of a file or directory. Calling a DirectoryEntry or FileEntry object's getMetadata() method results in a Metadata instance.

    -

    -Supported Platforms -

    +

    Supported Platforms

    • Amazon Fire OS
    • @@ -2482,9 +2389,8 @@ or directory. Calling a Quick Example - + +

      Quick Example

      function win(metadata) {
           console.log("Last Modified: " + metadata.modificationTime);
      @@ -2495,21 +2401,19 @@ entry.getMetadata(win, null);
       

      +

      FileError

      A FileError object is set when an error occurs in any of the File API methods.

      -

      -Properties -

      +

      Properties

      • code: One of the predefined error codes listed below.
      -

      -Constants -

      + +

      Constants

      -

      -Description -

      + +

      Description

      The FileError object is the only parameter provided to any of the File API's error callbacks. To determine the type of error, compare its code property to any of the listings above.


      +

      FileTransferError

      A FileTransferError object is passed to an error callback when an error occurs.

      -

      -Properties -

      +

      Properties

      • code: One of the predefined error codes listed below. (Number)

      • @@ -2548,9 +2450,8 @@ its code property to any of
      • target: URI to the target. (String)

      • http_status: HTTP status code. This attribute is only available when a response code is received from the HTTP connection. (Number)

      -

      -Constants -

      + +

      Constants

      -

      -Description -

      + +

      Description

      The FileTransferError object is passed to the error callback when an error occurs when uploading or downloading a file.

      @@ -2569,6 +2469,7 @@ error occurs when uploading or downloadi
    - - + + + Modified: cordova/site/public/docs/en/3.3.0/cordova_geolocation_geolocation.md.html URL: http://svn.apache.org/viewvc/cordova/site/public/docs/en/3.3.0/cordova_geolocation_geolocation.md.html?rev=1551686&r1=1551685&r2=1551686&view=diff ============================================================================== --- cordova/site/public/docs/en/3.3.0/cordova_geolocation_geolocation.md.html (original) +++ cordova/site/public/docs/en/3.3.0/cordova_geolocation_geolocation.md.html Tue Dec 17 20:31:35 2013 @@ -17,16 +17,18 @@ specific language governing permissions and limitations under the License. --> - - - - -Apache Cordova API Documentation - - - - - + + + + + + Apache Cordova API Documentation + + + + + +

    Geolocation

    @@ -220,36 +223,31 @@ above, as well as obtaining the user's p choices for OK and No Thanks). For more information, please see the Privacy Guide.

    -

    -Methods -

    +

    Methods

    -

    -Arguments -

    + +

    Arguments

    -

    -Objects (Read-Only) -

    + +

    Objects (Read-Only)

    -

    -Accessing the Feature -

    + +

    Accessing the Feature

    As of version 3.0, Cordova implements device-level APIs as plugins. Use the CLI's plugin command, described in The Command-Line @@ -330,10 +328,12 @@ platform-specific configuration settings

    Reference: Application Manifest for Windows Phone

    +

    Some platforms may support this feature without requiring any special configuration. See Platform Support for an overview.


    +

    geolocation.getCurrentPosition

    Returns the device's current position as a Position object.

    @@ -343,18 +343,15 @@ configuration. See geolocationOptions]);
    -

    -Parameters -

    +

    Parameters

    -

    -Description -

    + +

    Description

    geolocation.getCurrentPosition is an asynchronous function. It returns the device's current position to the geolocationSuccess @@ -362,9 +359,7 @@ callback with a geolocationError callback is passed a PositionError object.

    -

    -Supported Platforms -

    +

    Supported Platforms

    - - + + +