D0301
HTML Application SDK  A0.101
Classes | Public Member Functions | Public Attributes | List of all members
StorageManager Interface Reference

import"StorageManagerPlugin.idl";

Classes

interface  mediaFileReadProgressCompletedEvent
 
interface  mediaFileReadProgressEvent
 
interface  removableDeviceConnected
 
interface  removableDeviceDisconnected
 

Public Member Functions

void addEventListener ([in] String event_name, [in] EventListener listener)
 
StorageInfo checkEmptySpace ([in] String path)
 
StorageInfo checkTotalSize ([in] String path)
 
enumerations copy ([in] String filePath, [in] String newPath)
 
enumerations delete ([in] String filePath)
 
enumerations format ([in] String path)
 
Boolean getFileExistence ([in] String path)
 
String getFileMd5 ([in] String filePath)
 
Float getFileSize ([in] String filePath)
 
String getLastMountedUSBPath ()
 
RemovableDevice[] getListOfAvailableStorages ()
 
void getListOfPlayableFiles ([in] String path, [in] enumerations filetype)
 
Boolean isFormatRequired ([in] String path)
 
Boolean isInternalUSB ([in] String path)
 
enumerations listFiles ([in] String path)
 
enumerations makeDir ([in] String path)
 
void removeEventListener ([in] String event_name, [in] EventListener listener)
 
void removeEventListener ([in] String event_name)
 
enumerations rename ([in] String filePath, [in] String newName)
 
enumerations unzip ([in] String file, [in] String path)
 

Public Attributes

const Integer BadParameter = 7
 
const Integer DeviceTypeDlna = 1
 
const Integer DeviceTypeUsb = 0
 
const Integer DirAlreadyExists = 12
 
const Integer DirNotEmpty = 10
 
const Integer DirPathNotFound = 11
 
const Integer DiskFull = 8
 
const Integer DiskMissing = 9
 
const Integer EndOfData = 3
 
const Integer Ext2 = 3
 
const Integer Ext3 = 2
 
const Integer Fat = 0
 
const Integer FileNotFound = 1
 
const Integer MediaTypeAll = 4
 
const Integer MediaTypeAudio = 1
 
const Integer MediaTypePicture = 0
 
const Integer MediaTypeVideo = 2
 
const Integer MemoryAllocFail = 6
 
const Integer NoError = 0
 
const Integer Ntfs = 1
 
const Integer OpenError = 2
 
const Integer OperationFail = 14
 
const Integer PermissionDenied = 13
 
const Integer ReadError = 4
 
const Integer TypeFile = 0
 
const Integer TypeFolder = 1
 
const Integer TypeInvalid = 2
 
const Integer WriteError = 5
 

Detailed Description

This is a class which implements global StorageManager object.

Member Function Documentation

void StorageManager.addEventListener ( [in] String  event_name,
[in] EventListener  listener 
)

Adds DOM2 event listener for specified event.

Possible values are: event_name: "removableDeviceConnected", listener: function that has arguments similar to the removableDeviceConnected interface properties. event_name: "removableDeviceDisconnected", listener: function that has arguments similar to the removableDeviceDisconnected interface properties. event_name: "mediaFileReadProgressEvent", listener: function that has arguments similar to the mediaFileReadProgressEvent interface properties.

Parameters
event_nameName of the event.
listenerjavascript function that has arguments like the properties listed in the listener's interface.
StorageInfo StorageManager.checkEmptySpace ( [in] String  path)

This function returns the StorageInfo object. return value corresponds to the available space of removable device in kB and errorCode corresponds to the file system error code.

var spaceInfo = StorageManager.checkEmptySpace(usbPath);
expect(spaceInfo.errorCode).toBe(StorageManager.NoError, "Check empty space operation for a valid USB path cannot be done without error");
expect(spaceInfo.returnValue).toBeGreaterThan(0, "Check empty space operation for a valid USB path does not give nonzero free space information");
Parameters
pathabsolute path of removable device that will be checked for empty space
Returns
File System Errors: NoError:0, BadParameter:7, DiskMissing:9, OperationFail:14 / and available space
StorageInfo StorageManager.checkTotalSize ( [in] String  path)

This function returns the StorageInfo object. return value corresponds to the total size of removable device in kB and errorCode corresponds to the file system error code.

var spaceInfo = StorageManager.checkTotalSize(usbPath);
expect(spaceInfo.errorCode).toBe(StorageManager.NoError, "Check total size operation for a valid USB path cannot be done without error");
expect(spaceInfo.returnValue).toBeGreaterThan(0, "Check total size operation for a valid USB path does not give nonzero total size information");
Parameters
pathabsolute path of removable device that will be checked for total size
Returns
File System Errors: NoError:0, BadParameter:7, DiskMissing:9, OperationFail:14 / and total size
enumerations StorageManager.copy ( [in] String  filePath,
[in] String  newPath 
)

This function copies the file given to path given. Any folder can be copied by using this function only if the filePath ends with '/' character. If newPath belongs to an existing file, it overwrites the file and returns NoError. If newPath does not include a file extension and there is not a folder with the same name, it copies to the given path and returns NoError. If newPath does not include a file extension and there is a folder with the same name, it copies the file with original name to the folder and returns NoError.

StorageManager.copy(usbPath + "html_app_sdk_tests/manual/img/arrow_down_64x64.png", testFolder + "test_img");
Parameters
filePathabsolute path of the file that will be copied
newPathnew absolute path that the file will be copied to
Returns
File System Errors: NoError:0, OpenError:2, BadParameter:7, PermissionDenied:13, OperationFail:14
enumerations StorageManager.delete ( [in] String  filePath)

This function deletes the file or the folder given. It deletes the folder even it is not empty, so consider this while calling delete function.

var errorCode = StorageManager.delete(testFolder + "test11_img/");
Parameters
filePathabsolute path of the file that will be deleted
Returns
File System Errors: NoError:0, FileNotFound:1, MemoryAllocFail:6, PermissionDenied:13, OperationFail:14
enumerations StorageManager.format ( [in] String  path)

This function formats removable device given.

var lastmountedUSB = StorageManager.getLastMountedUSBPath();
StorageManager.format(lastmountedUSB);
Parameters
pathabsolute path of removable device that will be formatted
Returns
File System Errors: NoError:0, BadParameter:7, PermissionDenied:13, OperationFail:14
Boolean StorageManager.getFileExistence ( [in] String  path)

This function checks whether the file/folder in the given path exists.

var fileExist = StorageManager.getFileExistence(usbPath + "/html_app_sdk_tests/index.html");
Parameters
pathabsolute path of the file that will be checked
Returns
true if the file exists; false, otherwise.
String StorageManager.getFileMd5 ( [in] String  filePath)

This function returns MD5 of a file stored on the storage. It will throw 'Invalid file' exception if file does not exist, path is not valid, or it is not accessible. It will throw 'File read error' exception if file cannot be opened.

var md5Hash = StorageManager.getFileMd5(usbPath + "html_app_sdk_tests/manual/img/arrow_down_64x64.png");
Parameters
filePathabsolute path of the file whose MD5 will be get
Returns
MD5 of the file on success; empty string, otherwise.
Float StorageManager.getFileSize ( [in] String  filePath)

This function returns the size of a given file in kB. It will throw 'Invalid file' exception if file does not exist, path is not valid, or it is not accessible.

var fileSize = StorageManager.getFileSize(filePath);
Parameters
filePathabsolute path of the file whose size will be get
Returns
Size of the file.
String StorageManager.getLastMountedUSBPath ( )

This function returns the path where the last external USB is mounted.

var lastmountedUSB = StorageManager.getLastMountedUSBPath();
Returns
Last mounted USB on success; throws error if no USB is mounted.
RemovableDevice [] StorageManager.getListOfAvailableStorages ( )

This function returns avaliable storages.

Returns
List of removable devices
void StorageManager.getListOfPlayableFiles ( [in] String  path,
[in] enumerations  filetype 
)

This function sets mediaFileReadProgressEvent. List will be sent through mediaFileReadProgressEvent event and when progress is finished,mediaFileReadProgressCompletedEvent will come.

Parameters
pathAbsolute path of a removable device. In case of wrong path that does not corresspond a removable device it will throw 'Not a removable device path' exception
filetypeType of file which is wanted to be listed: MediaTypePicture:0, MediaTypeAudio:1, MediaTypeVideo:2, MediaTypeAll:4
Boolean StorageManager.isFormatRequired ( [in] String  path)

This function checks whether format of given device is required or not.

Parameters
pathabsolute path of removable device that will be checked
Returns
true if format is required; false, otherwise.
Boolean StorageManager.isInternalUSB ( [in] String  path)

This function checks whether the given device is internal or external device.

Parameters
pathabsolute path of removable device that will be checked
Returns
true if the device is internal; false, otherwise.
enumerations StorageManager.listFiles ( [in] String  path)

This function sets mediaFileReadProgressEvent. List will be sent through mediaFileReadProgressEvent event and when progress is finished,mediaFileReadProgressCompletedEvent will come.

var errorCode = StorageManager.listFiles(usbPath + "html_app_sdk_tests/");
Parameters
pathabsolute path of the directory under that files will be listed.
Returns
File System Errors: NoError:0, FileNotFound:1, BadParameter:7, PermissionDenied:13, OperationFail:14
enumerations StorageManager.makeDir ( [in] String  path)

This function creates new folder.

testFolder = usbPath + "storage_manager_tests/";
StorageManager.makeDir(testFolder);
Parameters
pathabsolute path of the file that will be created
Returns
File System Errors: NoError:0, DirPathNotFound:11, DirAlreadyExists:12, PermissionDenied:13, OperationFail:14
void StorageManager.removeEventListener ( [in] String  event_name,
[in] EventListener  listener 
)

Removes single DOM2 event listener for specified event

Possible values are: event_name: "removableDeviceConnected", listener: function that has arguments similar to the removableDeviceConnected interface properties. event_name: "removableDeviceDisconnected", listener: function that has arguments similar to the removableDeviceDisconnected interface properties. event_name: "mediaFileReadProgressEvent", listener: function that has arguments similar to the mediaFileReadProgressEvent interface properties.

Parameters
event_nameName of the event
listenernamed javascript function that has arguments like the properties listed in the listener's interface.
void StorageManager.removeEventListener ( [in] String  event_name)

Removes all DOM2 event listeners for specified event

Parameters
event_nameName of the event
See also
removeEventListener([in] String event_name, [in] EventListener listener);
enumerations StorageManager.rename ( [in] String  filePath,
[in] String  newName 
)

This function moves the file or folder given to the path given. If the given path belongs to an existing non-empty folder, it does not overwrite this folder and returns DirAlreadyExists. If the given path belongs to an existing empty folder, it overwrites this folder and returns NoError. If the given path belongs to an existing file, it overwrites the file and returns NoError.

var errorCode = StorageManager.rename(testFolder + "test0_img/", testFolder + "test0_img_renamed");
Parameters
filePathabsolute path of the file that will be renamed
newNamenew name with absolute path of the file
Returns
File System Errors: NoError:0, FileNotFound:1, DirAlreadyExists:12, PermissionDenied:13, OperationFail:14
enumerations StorageManager.unzip ( [in] String  file,
[in] String  path 
)

This function decompresses the zip file given.

var errorCode = StorageManager.unzip(usbPath + "html_app_sdk_tests/resource/unzip.zip", testFolder + "unzip");
Parameters
fileabsolute path of zip file that will be extracted
pathabsolute path where zip file will be extracted into
Returns
File System Errors: NoError:0, DirPathNotFound:11, DirAlreadyExists:12, PermissionDenied:13, OperationFail:14

Member Data Documentation

const Integer StorageManager.BadParameter = 7

An invalid parameter was passed to the function.

const Integer StorageManager.DeviceTypeDlna = 1

Removable device type

const Integer StorageManager.DeviceTypeUsb = 0

Removable device type

const Integer StorageManager.DirAlreadyExists = 12

Attempt was made to create a directory that already exists.

const Integer StorageManager.DirNotEmpty = 10

Attempt was made to delete a directory that is not empty.

const Integer StorageManager.DirPathNotFound = 11

Attempt was made to create a directory with a filespec that

const Integer StorageManager.DiskFull = 8

The relevant disk is full.

const Integer StorageManager.DiskMissing = 9

The drive's removable disk is not present – for future support.

const Integer StorageManager.EndOfData = 3

End of data was reached. This is end of file

const Integer StorageManager.Ext2 = 3

Removable device file system format ext2

const Integer StorageManager.Ext3 = 2

Removable device file system format ext3

const Integer StorageManager.Fat = 0

Removable device file system format fat

const Integer StorageManager.FileNotFound = 1

An invalid parameter was passed to the function.

const Integer StorageManager.MediaTypeAll = 4

Media type all

const Integer StorageManager.MediaTypeAudio = 1

Media type audio

const Integer StorageManager.MediaTypePicture = 0

Media type picture

const Integer StorageManager.MediaTypeVideo = 2

Media type video

const Integer StorageManager.MemoryAllocFail = 6

Unable to allocate memory within the implementation of a function.

const Integer StorageManager.NoError = 0

Operation completed successfully.

const Integer StorageManager.Ntfs = 1

Removable device file system format ntfs

const Integer StorageManager.OpenError = 2

Error attempting to open or create a file.

const Integer StorageManager.OperationFail = 14

An unspecified error occurred.

const Integer StorageManager.PermissionDenied = 13

Attempt to access a file or folder at invalid removable device path.

const Integer StorageManager.ReadError = 4

Error occurred reading data from the disk.

const Integer StorageManager.TypeFile = 0

Type file

const Integer StorageManager.TypeFolder = 1

Type folder

const Integer StorageManager.TypeInvalid = 2

Type invalid

const Integer StorageManager.WriteError = 5

Error occurred writing data to the disk.


The documentation for this interface was generated from the following file: