PhoneGap - File System Actions (File URI Based)

Description

Performs actions with the mobile device file system such as creating, reading, deleting file, creating directories, deleting directories, etc. (Only applies to UX components running in a Cordova shell.)

These actions give you explicit control over the exact location in the device's file system where the file operations will occur.

Used with the UX component.

File System Action Properties

Action name

Specify the File System Action that you want to perform.

File System Is Available Properties

Variable

Specify the variable to set. Variable will be set to true or false.

Get Base URI of Requested File System Part Properties

File system part

Specify the part of the file system. 'persistent' refers to the file system used by the non-uri based file system actions. It is the location specified by the Cordova constant: LocalFileSystem.PERSISTENT Choices include temp, private, saved, public, persistent.

Variable

Specify the variable to set.

Read a File Properties

File system part

Specify which part of the file system the file you want to read is located in. If you want to use an explicit base path (which must end with a forward slash) select <explicit>. 'persistent' refers to the file system used by the non-uri based file system actions. It is the location specified by the Cordova constant: LocalFileSystem.PERSISTENT Choices include temp, private, saved, public, persistent, <explicit>.

Explicit base URI

Specify the URI for the base folder. For example: file:///data/user/0/com.alpha.app1/files/files/

File name

Specify the name of the file you want to read. You must specify a relative filename (e.g. 'file1.txt') . The filename is relative to the folder specified by the 'File system part' setting (or the 'Explicit base URI' if you set the 'File system part' to <explicit>). You can define a Javascript function to return the file name. Enter: javascript:yourfunctionname. For example: javascript:getFilename

Start at

Specify the byte location where to start reading. Set to -1 to start at the beginning of the file. If you specify a value other than -1 you must also specify a value for the End at property that is not -1.

End at

Specify the byte location where to stopt reading. Set to -1 to end at the end of the file. If you specify a value other than -1 you must also specify a value for the Start at property that is not -1.

onSuccess Javascript

Specify the Javascript to run once the file has been read.

onError Javascript

onError Javascript property.

Write a File Properties

File system part

Specify which part of the file system the file you want to write is located in. If you want to use an explicit base path (which must end with a forward slash) select <explicit>. 'persistent' refers to the file system used by the non-uri based file system actions. It is the location specified by the Cordova constant: LocalFileSystem.PERSISTENT Choices include temp, private, saved, public, persistent, <explicit>.

Explicit base URI

Specify the URI for the base folder. For example: file:///data/user/0/com.alpha.app1/files/files/

File name

Specify the name of the file you want to write. You must specify a relative filename (e.g. 'file1.txt') . The filename is relative to the folder specified by the 'File system part' setting (or the 'Explicit base URI' if you set the 'File system part' to <explicit>). You can define a Javascript function to return the file name. Enter: javascript:yourfunctionname. For example: javascript:getFilename

Text to write

Specify the text to write. You can call a Javascript function to get the text by entering: javascript:functionName. For example: javascript:getText

Append

If the file already exists, should the contents be appended to the existing file?

onSuccess Javascript

Specify the Javascript to run once the file has been writen.

onError Javascript

onError Javascript property.

Check if file exists (and get file properties) Properties

File system part

Specify in which part of the file system the file you want to check is located. If you want to use an explicit base path (which must end with a forward slash) select <explicit>. 'persistent' refers to the file system used by the non-uri based file system actions. It is the location specified by the Cordova constant: LocalFileSystem.PERSISTENT Choices include temp, private, saved, public, persistent, <explicit>.

Explicit base URI

Specify the URI for the base folder. For example: file:///data/user/0/com.alpha.app1/files/files/

File name

Specify the name of the file you want to check. You must specify a relative filename (e.g. 'file1.txt') . The filename is relative to the folder specified by the 'File system part' setting (or the 'Explicit base URI' if you set the 'File system part' to <explicit>). You can define a Javascript function to return the file name. Enter: javascript:yourfunctionname. For example: javascript:getFilename

onResult Javascript

Specify the Javascript to run once a result is available.

onError Javascript

onError Javascript property.

Delete a file Properties

File system part

Specify which in part of the file system the file you want to delete is located. If you want to use an explicit base path (which must end with a forward slash) select <explicit>.'persistent' refers to the file system used by the non-uri based file system actions. It is the location specified by the Cordova constant: LocalFileSystem.PERSISTENT Choices include temp, private, saved, public, persistent, <explicit>.

Explicit base URI

Specify the URI for the base folder. For example: file:///data/user/0/com.alpha.app1/files/files/

File name

Specify the name of the file you want to delete. You must specify a relative filename (e.g. 'file1.txt') . The filename is relative to the folder specified by the 'File system part' setting (or the 'Explicit base URI' if you set the 'File system part' to <explicit>). You can define a Javascript function to return the file name. Enter: javascript:yourfunctionname. For example: javascript:getFilename

onDeleteSuccess Javascript

Specify the Javascript to run once the file has been deleted.

onError Javascript

onError Javascript property.

Copy a file Properties

Source - File system part

Specify which in part of the file system the file you want to copy is located. If you want to use an explicit base path (which must end with a forward slash) select <explicit>. 'persistent' refers to the file system used by the non-uri based file system actions. It is the location specified by the Cordova constant: LocalFileSystem.PERSISTENT Choices include temp, private, saved, public, persistent, <explicit>.

Source - Explicit base URI

Specify the URI for the base folder. For example: file:///data/user/0/com.alpha.app1/files/files/

Source - File name

Specify the name of the file you want to copy. You must specify a relative filename (e.g. 'file1.txt') . The filename is relative to the folder specified by the 'Source - File system part' setting (or the 'Source - Explicit base URI' if you set the 'Source - File system part' to <explicit>). You can define a Javascript function to return the file name. Enter: javascript:yourfunctionname. For example: javascript:getFilename

Target - File system part

Specify to which part of the file system the file you want to copy the file. If you want to use an explicit base path (which must end with a forward slash) select <explicit>. Choices include temp, private, saved, public, persistent, <explicit>.

Target - Explicit base URI

Specify the URI for the target base folder. For example: file:///data/user/0/com.alpha.app1/files/files/

Target - File name

Specify the name of the copied file. If you leave this blank, the 'Source - File name' will be used. You must specify a relative filename (e.g. 'file1.txt') . The filename is relative to the folder specified by the 'Target - File system part' setting (or the 'Target - Explicit base URI' if you set the 'File system part' to <explicit>). You can define a Javascript function to return the file name. Enter: javascript:yourfunctionname. For example: javascript:getFilename

onCopySuccess Javascript

Specify the Javascript to run once the file has been copied

onError Javascript

onError Javascript property.

Move a file Properties

Source - File system part

Specify which in part of the file system the file you want to move is located. If you want to use an explicit base path (which must end with a forward slash) select <explicit>. 'persistent' refers to the file system used by the non-uri based file system actions. It is the location specified by the Cordova constant: LocalFileSystem.PERSISTENT Choices include temp, private, saved, public, persistent, <explicit>.

Source - Explicit base URI

Specify the URI for the base folder. For example: file:///data/user/0/com.alpha.app1/files/files/

Source - File name

Specify the name of the file you want to copy. You must specify a relative filename (e.g. 'file1.txt') . The filename is relative to the folder specified by the 'Source - File system part' setting (or the 'Source - Explicit base URI' if you set the 'Source - File system part' to <explicit>). You can define a Javascript function to return the file name. Enter: javascript:yourfunctionname. For example: javascript:getFilename

Target - File system part

Specify to which part of the file system the file you want to move the file. If you want to use an explicit base path (which must end with a forward slash) select <explicit>. 'persistent' refers to the file system used by the non-uri based file system actions. It is the location specified by the Cordova constant: LocalFileSystem.PERSISTENT Choices include temp, private, saved, public, persistent, <explicit>.

Target - Explicit base URI

Specify the URI for the target base folder. For example: file:///data/user/0/com.alpha.app1/files/files/

Target - File name

Specify the name of the copied file. If you leave this blank, the 'Source - File name' will be used. You must specify a relative filename (e.g. 'file1.txt') . The filename is relative to the folder specified by the 'Target - File system part' setting (or the 'Target - Explicit base URI' if you set the 'File system part' to <explicit>). You can define a Javascript function to return the file name. Enter: javascript:yourfunctionname. For example: javascript:getFilename

onMoveSuccess Javascript

Specify the Javascript to run once the file has been moved.

onError Javascript

onError Javascript property.

Remove a directory (recursively) Properties

File system part

Specify in which part of the file system the directory you want to remove is located. If you want to use an explicit base path (which must end with a forward slash) select <explicit>. 'persistent' refers to the file system used by the non-uri based file system actions. It is the location specified by the Cordova constant: LocalFileSystem.PERSISTENT Choices include temp, private, saved, public, persistent, <explicit>.

Explicit base URI

Specify the URI for the base folder. For example: file:///data/user/0/com.alpha.app1/files/files/

Directory name

Specify the name of the directory you want to remove. IMPORTANT: The name must end with a / (forward slash). You can define a Javascript function to return the directory name. Enter: javascript:yourfunctionname. For example: javascript:getDirname

onSuccess Javascript

Specify the Javascript to run once the directories have been removed.

onError Javascript

onError Javascript property.

Create directories (recursively) Properties

File system part

Specify in which part of the file system the directories you want to create should be located. If you want to use an explicit base path (which must end with a forward slash) select <explicit>. 'persistent' refers to the file system used by the non-uri based file system actions. It is the location specified by the Cordova constant: LocalFileSystem.PERSISTENT Choices include temp, private, saved, public, persistent, <explicit>.

Explicit base URI

Specify the URI for the base folder. For example: file:///data/user/0/com.alpha.app1/files/files/

Directory structure

Specify the directory structure you want to create. Example: /dir1/subdir1/subsubdir1. The directory structure is relative to the base URI (specified by the File system part). If the directories already exist, then no action is taken and the onSuccess function is called. You can define a Javascript function to return the directory structure. Enter: javascript:yourfunctionname. For example: javascript:getDirStructure

onSuccess Javascript

Specify the Javascript to run once the direcories have been created (or verified to exist).

onError Javascript

onError Javascript property.

List files in a directory (recursively) Properties

File system part

Specify in which part of the file system the directories you want to examine are located. If you want to use an explicit base path (which must end with a forward slash) select <explicit>. 'persistent' refers to the file system used by the non-uri based file system actions. It is the location specified by the Cordova constant: LocalFileSystem.PERSISTENT Choices include temp, private, saved, public, persistent, <explicit>.

Explicit base URI

Specify the URI for the base folder. For example: file:///data/user/0/com.alpha.app1/files/files/

Directory name

Specify the name of the directory you want to examine. The directory is relative to the 'File system part'. IMPORTANT: The name must end with a / (forward slash). You can define a Javascript function to return the directory name. Enter: javascript:yourfunctionname. For example: javascript:getDirname

onSuccess Javascript

Specify the Javascript to run once a result is available.

onError Javascript

onError Javascript property.

List matching files in a directory Properties

File system part

Specify in which part of the file system the directory you want to examine is located. If you want to use an explicit base path (which must end with a forward slash) select <explicit>. 'persistent' refers to the file system used by the non-uri based file system actions. It is the location specified by the Cordova constant: LocalFileSystem.PERSISTENT Choices include temp, private, saved, public, persistent, <explicit>.

Explicit base URI

Specify the URI for the base folder. For example: file:///data/user/0/com.alpha.app1/files/files/

Directory name

Specify the name of the directory you want to examine. The directory is relative to the 'File system part'. IMPORTANT: The name must end with a / (forward slash). You can define a Javascript function to return the directory name. Enter: javascript:yourfunctionname. For example: javascript:getDirname

Match regular expression

(Optional). Specify a regular expression. Only filenames that match the regular expression are listed when the onSuccess function is called.

onSuccess Javascript

Specify the Javascript to run once a result is available.

onError Javascript

onError Javascript property.

Delete matching files Properties

File system part

Specify in which part of the file system the directory from which you want to delete files is located. If you want to use an explicit base path (which must end with a forward slash) select <explicit>. 'persistent' refers to the file system used by the non-uri based file system actions. It is the location specified by the Cordova constant: LocalFileSystem.PERSISTENT Choices include temp, private, saved, public, persistent, <explicit>.

Explicit base URI

Specify the URI for the base folder. For example: file:///data/user/0/com.alpha.app1/files/files/

Directory name

Specify the name of the directory from which you want to delete files. The directory is relative to the 'File system part'. IMPORTANT: The name must end with a / (forward slash). You can define a Javascript function to return the directory name. Enter: javascript:yourfunctionname. For example: javascript:getDirname

Match regular expression

(Optional). Specify a regular expression. Only filenames that match the regular expression are deleted (as long as the file is not listed in the 'keep' list).

Keep list

(Optional). Specify files to NOT delete (even if they match the regular expression). Enter a comma delimited list of filenames. Alternative you can call a javascript function by specifying: javascript:myKeepList. Your Javascript function MUST return an array of filenames to keep.

onComplete Javascript

Specify the Javascript to run once the file(s) have been deleted

onError Javascript

onError Javascript property.

See Also