Directory
The Directory object provides functions for interacting with directories on the file system.
See also blackberry.io.file
Supported Platform(s)
- BlackBerry OS 5.0+ |
- BlackBerry PlayBook 1.0+ |
- Ripple Emulator |
API | BB5.0 | BB6.0 | BB7.0 | PB1.0 | PB2.0 | BB10 | Ripple |
---|---|---|---|---|---|---|---|
blackberry.io.dir.createNewDir | Y | Y | Y | Y | Y | Y | |
blackberry.io.dir.deleteDirectory | Y | Y | Y | Y | Y | Y | |
blackberry.io.dir.exists | Y | Y | Y | Y | Y | Y | |
blackberry.io.dir.getFreeSpaceForRoot | Y | Y | Y | Y | |||
blackberry.io.dir.getParentDirectory | Y | Y | Y | Y | Y | Y | |
blackberry.io.dir.getRootDirs | Y | Y | Y | Y | |||
blackberry.io.dir.listDirectories | Y | Y | Y | Y | Y | Y | |
blackberry.io.dir.listFiles | Y | Y | Y | Y | Y | Y | |
blackberry.io.dir.rename | Y | Y | Y | Y | Y | Y | |
http://localhost:8472/blackberry/io/dir/appDirs | Y | Y | |||||
http://localhost:8472/blackberry/io/dir/create | Y | Y | |||||
http://localhost:8472/blackberry/io/dir/delete | Y | Y | |||||
http://localhost:8472/blackberry/io/dir/exists | Y | Y | |||||
http://localhost:8472/blackberry/io/dir/get | Y | Y | |||||
http://localhost:8472/blackberry/io/dir/list | Y | Y | |||||
http://localhost:8472/blackberry/io/dir/parent | Y | Y | |||||
http://localhost:8472/blackberry/io/dir/rename | Y | Y | |||||
appDirs | Y | Y | Y |
Configuration Document Settings
To use all of the API described for this object, you must ensure the following settings are in your configuration document: |
You must declare the feature element(s) below in your configuration document: |
Feature ID | BB5.0 | BB6.0 | BB7.0 | PB1.0 | PB2.0 | BB10 | Ripple |
---|---|---|---|---|---|---|---|
<feature id="blackberry.io.dir" /> | Y | Y | Y | Y | Y | Y |
Permission Elements (PlayBook and BlackBerry 10+) |
---|
Declaring the permission element(s) below in your configuration document is optional.
|
- <rim:permit>access_shared</rim:permit>
Any references to files/directories under "shared" folder (e.g. music) requires this permission to be set. |
Functions
void | blackberry.io.dir.createNewDir |
void | blackberry.io.dir.deleteDirectory |
Boolean | blackberry.io.dir.exists |
Number | blackberry.io.dir.getFreeSpaceForRoot |
String | blackberry.io.dir.getParentDirectory |
String[] | blackberry.io.dir.getRootDirs |
String[] | blackberry.io.dir.listDirectories |
String[] | blackberry.io.dir.listFiles |
void | blackberry.io.dir.rename |
Properties
Object | appDirs |
URI Functions
Object Literal | http://localhost:8472/blackberry/io/dir/appDirs |
Object Literal | http://localhost:8472/blackberry/io/dir/create |
Object Literal | http://localhost:8472/blackberry/io/dir/delete |
Object Literal | http://localhost:8472/blackberry/io/dir/exists |
Object Literal | http://localhost:8472/blackberry/io/dir/get |
Object Literal | http://localhost:8472/blackberry/io/dir/list |
Object Literal | http://localhost:8472/blackberry/io/dir/parent |
Object Literal | http://localhost:8472/blackberry/io/dir/rename |
Functions
static
void
blackberry.io.dir.createNewDir
(path : String)
Create an empty directory.
Supported Platforms | |
---|---|
- BlackBerry OS 5.0+ | |
- BlackBerry PlayBook 1.0+ | |
- Ripple Emulator |
Parameters | |
---|---|
path | path location of the new directory. The name of the new directory should be included as parts of the path. |
static
void
blackberry.io.dir.deleteDirectory
(path : String, [recursive : Boolean])
Delete a given directory. The directory has to be empty unless the recursive flag is set to true.
Supported Platforms | |
---|---|
- BlackBerry OS 5.0+ | |
- BlackBerry PlayBook 1.0+ | |
- Ripple Emulator |
Parameters | |
---|---|
path | path of the directory to be deleted. |
recursive | flag to decide if all contents should be deleted |
static
Boolean
blackberry.io.dir.exists
(path : String)
Determine whether a given directory exists or not. Returns true if the path exists and points to a directory, false otherwise.
Supported Platforms | |
---|---|
- BlackBerry OS 5.0+ | |
- BlackBerry PlayBook 1.0+ | |
- Ripple Emulator |
Parameters | |
---|---|
path | path location of the directory. |
static
Number
blackberry.io.dir.getFreeSpaceForRoot
(rootPath : String)
Get the amount of free space available in the specified root.
Supported Platforms | |
---|---|
- BlackBerry OS 5.0+ | |
- Ripple Emulator |
Parameters | |
---|---|
rootPath | Root path location to determine free space for. |
Return:
The amound of free space availalble in the specified root.
static
String
blackberry.io.dir.getParentDirectory
(path : String)
Returns the path location of the directory that the give file or directory resides in.
Supported Platforms | |
---|---|
- BlackBerry OS 5.0+ | |
- BlackBerry PlayBook 1.0+ | |
- Ripple Emulator |
Parameters | |
---|---|
path | Path of the directory or file. |
static
String[]
blackberry.io.dir.getRootDirs
()
Get a list of root directories.
Supported Platforms | |
---|---|
- BlackBerry OS 5.0+ | |
- Ripple Emulator |
Code Example:
|
static
String[]
blackberry.io.dir.listDirectories
(path : String)
List all the directories that reside in a given directory.
Supported Platforms | |
---|---|
- BlackBerry OS 5.0+ | |
- BlackBerry PlayBook 1.0+ | |
- Ripple Emulator |
Parameters | |
---|---|
path | path location of the directory. |
static
String[]
blackberry.io.dir.listFiles
(path : String)
List all the files that reside in a given directory.
Supported Platforms | |
---|---|
- BlackBerry OS 5.0+ | |
- BlackBerry PlayBook 1.0+ | |
- Ripple Emulator |
Parameters | |
---|---|
path | Path location of the directory. |
static
void
blackberry.io.dir.rename
(path : String, newDirectoryName : String)
Rename a given directory.
Supported Platforms | |
---|---|
- BlackBerry OS 5.0+ | |
- BlackBerry PlayBook 1.0+ | |
- Ripple Emulator |
Parameters | |
---|---|
path | path location of the directory to be renamed. |
newDirectoryName | the new name for the directory. |
Properties
static
readonly
Object
appDirs
Gets the full paths of application storage folder and sub-folders under "shared". Paths are in the form of file:// URL
The application storage folder is created when you first access blackberry.io.dir.appDirs. This directory is a convenient location to store application-specific data that can only be accessed by the application.
The "shared" folder is the parent directory to the sub-folders such as camera and music, which can be accessed by all applications. These sub-folders can also be accessed when the BlackBerry PlayBook has "File Sharing"
turned on. The access_shared permission must be set in order to reference any files/folders under "shared".
Supported Platforms | |
---|---|
- BlackBerry PlayBook 1.0+ | |
- Ripple Emulator |
Code Example:
|
URI Functions
http://localhost:8472/blackberry/io/dir/appDirs
Gets the full paths of application storage folder and sub-folders under "shared". Paths are in the form of file:// URL
The application storage folder is created when you first invoke this call. This directory is a convenient location to store application-specific data that can only be
accessed by the application.
The "shared" folder is the parent directory to the sub-folders such as camera and music, which can be accessed by all applications. These sub-folders can also be accessed when the
BlackBerry PlayBook has "File Sharing" turned on. The access_shared permission must be set in order to reference any files/folders under "shared".
Supported Platforms | |
---|---|
- BlackBerry PlayBook 1.0+ |
Return:
{ "data" : { "app": { "storage" : { "path" : "file:///accounts/1000/appdata/WebWorksAppTemplate.testa3NBcHBUZW1wbGF0ZSAgICA/data" } }, "shared": { "bookmarks": { "path" : "file:///accounts/1000/appdata/WebWorksAppTemplate.testa3NBcHBUZW1wbGF0ZSAgICA/shared/bookmarks" }, "books": { "path" : "file:///accounts/1000/appdata/WebWorksAppTemplate.testa3NBcHBUZW1wbGF0ZSAgICA/shared/books" }, "camera": { "path" : "file:///accounts/1000/appdata/WebWorksAppTemplate.testa3NBcHBUZW1wbGF0ZSAgICA/shared/camera" }, "documents": { "path" : "file:///accounts/1000/appdata/WebWorksAppTemplate.testa3NBcHBUZW1wbGF0ZSAgICA/shared/documents" }, "downloads": { "path" : "file:///accounts/1000/appdata/WebWorksAppTemplate.testa3NBcHBUZW1wbGF0ZSAgICA/shared/downloads" }, "misc": { "path" : "file:///accounts/1000/appdata/WebWorksAppTemplate.testa3NBcHBUZW1wbGF0ZSAgICA/shared/misc" }, "music": { "path" : "file:///accounts/1000/appdata/WebWorksAppTemplate.testa3NBcHBUZW1wbGF0ZSAgICA/shared/music" }, "photos": { "path" : "file:///accounts/1000/appdata/WebWorksAppTemplate.testa3NBcHBUZW1wbGF0ZSAgICA/shared/photos" }, "print": { "path" : "file:///accounts/1000/appdata/WebWorksAppTemplate.testa3NBcHBUZW1wbGF0ZSAgICA/shared/print" }, "videos": { "path" : "file:///accounts/1000/appdata/WebWorksAppTemplate.testa3NBcHBUZW1wbGF0ZSAgICA/shared/videos" }, "voice": { "path" : "file:///accounts/1000/appdata/WebWorksAppTemplate.testa3NBcHBUZW1wbGF0ZSAgICA/shared/voice" } } } }
http://localhost:8472/blackberry/io/dir/create
Create an empty directory.
Supported Platforms | |
---|---|
- BlackBerry PlayBook 1.0+ |
Parameters | |
---|---|
path | path of the directory to be created, the name of the new directory should be included as parts of the path, specified in the form of file:/// URL |
Return:
{ "data" : { "path": "<path that was passed>" } }
http://localhost:8472/blackberry/io/dir/delete
Delete a given directory. The directory has to be empty unless the recursive flag is set to true.
Supported Platforms | |
---|---|
- BlackBerry PlayBook 1.0+ |
Parameters | |
---|---|
path | path of the directory to be deleted, specified in the form of file:/// URL |
recursive | flag to decide if all contents should be deleted, defaulted to false |
Return:
{ "data" : { "path": "<path that was passed>", "recursive" : the boolean that was passed (false if "recursive" was not specified) } }
http://localhost:8472/blackberry/io/dir/exists
Determine whether a given directory exists or not.
Supported Platforms | |
---|---|
- BlackBerry PlayBook 1.0+ |
Parameters | |
---|---|
path | path of the directory, specified in the form of file:/// URL |
Return:
{ "data" : { "path": "<path that was passed>", "exists" : true if the path exists and points to a directory, false otherwise } }
http://localhost:8472/blackberry/io/dir/get
Get properties for a given directory.
Supported Platforms | |
---|---|
- BlackBerry PlayBook 1.0+ |
Parameters | |
---|---|
path | path of the directory, specified in the form of file:/// URL |
Return:
{ "data" : { "path": "<path that was passed>", "name": "<name of the directory>", // only defined if "code" is 0 "spaceAvailable": <space available for use at this directory, in bytes>, // only defined if "code" is 0 "isEmpty": true (if directory does not contain files or sub-directories) or false (if directory contains files or sub-directories), // only defined if "code" is 0 } }
http://localhost:8472/blackberry/io/dir/list
List all the files and subdirectories that reside in a given directory.
Supported Platforms | |
---|---|
- BlackBerry PlayBook 1.0+ |
Parameters | |
---|---|
path | path of the directory or file, specified in the form of file:/// URL |
Return:
{ "data" : { "path": "<path that was passed>", "directories" : [ "folder1", "folder2" ], // only defined if "code" is 0 "files" : [ "5-snowflakes.swf", "chromeBookmarks.html", "test.txt ] // only defined if "code" is 0 } }
Code Example:
|
http://localhost:8472/blackberry/io/dir/parent
Gets the path location of the directory that the give file or directory resides in.
Supported Platforms | |
---|---|
- BlackBerry PlayBook 1.0+ |
Parameters | |
---|---|
path | path of the directory or file, specified in the form of file:/// URL |
Return:
{ "data" : { "path": "<path that was passed>", "directory" : "<parent directory>" // only defined if "code" is 0 } }
http://localhost:8472/blackberry/io/dir/rename
Rename a given directory.
Supported Platforms | |
---|---|
- BlackBerry PlayBook 1.0+ |
Parameters | |
---|---|
path | path of the directory, specified in the form of file:/// URL |
newDirectoryName | new name for the directory |
Return:
{ "data" : { "path": "<path that was passed>", "newDirectoryName" : "<newDirectoryName that was passed>" } }