Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface...

20
Tizen - Web Application Input/Output Filesystem API

Transcript of Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface...

Page 1: Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface access the Filesystem API •Methods resolve To access the file by Resolving location

Tizen - Web Application

Input/Output Filesystem API

Page 2: Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface access the Filesystem API •Methods resolve To access the file by Resolving location

Ajou Univrsity

Contents

• Filesystem API

• Interfaces of Filesystem API

• Filesystem Success Callback

Page 3: Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface access the Filesystem API •Methods resolve To access the file by Resolving location

Ajou Univrsity

Filesystem API

Page 4: Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface access the Filesystem API •Methods resolve To access the file by Resolving location

Ajou Univrsity

Filesystem API

• Filesystem API • The API which access the Device’s Filesystem

• The following virtual roots were supported:

• Filesystem API support the File URI(Virtual root: /tmp/, ‘file:///tmp)

• Privileges • http://tizen.org/privilege/filesystem.read

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

Image 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)

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

Page 5: Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface access the Filesystem API •Methods resolve To access the file by Resolving location

Ajou Univrsity

Interface of Filesystem API

Page 6: Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface access the Filesystem API •Methods resolve To access the file by Resolving location

Ajou Univrsity

FilesystemManager

• FilesystemManager • The interface access the Filesystem API

• Methods

resolve To access the file by Resolving location

getStorage To bring information in the Storage

listStorages To show the Storage list in device

addStorageStateChangeListener To indicate a change in the storage

addStorageStateChangeListener To indicate change of storage removal

Page 7: Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface access the Filesystem API •Methods resolve To access the file by Resolving location

Ajou Univrsity

FilesystemManager

• FilesystemManager • Example of FilesystemManager

Handling a file with Resolve method

Perform the funcion(dir) in Success Method

Perform onsuccess in dir.listFilesd in Success method

To create test.txt

To write “HelloWorld” in file on Write mode and close it

To show the created file on Console window

Page 8: Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface access the Filesystem API •Methods resolve To access the file by Resolving location

Ajou Univrsity

FilesystemStorage

• FilesystemStorage • The interface of additional Storage(Information of Device’s mount,

name, Removal)

• Attributes

readonly DOMString label Name of Storage

readonly FileSystemStorageType type Type of Storage

readonly FileSystemStorageState state State of Storage ( mount or not)

Page 9: Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface access the Filesystem API •Methods resolve To access the file by Resolving location

Ajou Univrsity

File

• File • The interface of File abstraction (According to isFile property)

Page 10: Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface access the Filesystem API •Methods resolve To access the file by Resolving location

Ajou Univrsity

File

• File

• Attributes

readonly File parent Parent Directory

readonly boolean readOnly State of the access in File/Directory

readonly boolean isFile The attribute whether File or not

readonly boolean isDirectory The attribute whether Directory or not

readonly Date created Information on a timestamp file is created

readonly Date modified Information on a timestamp file is modified

readonly DOMString path Information about the file’s location (except file name)

readonly DOMString fullPath The whole information about the file

readonly long length The number of file and directory in File handle

Page 11: Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface access the Filesystem API •Methods resolve To access the file by Resolving location

Ajou Univrsity

File

• File • Methods

toURI Returns a URI for a file

listFiles Lists all files in a directory

openStream Opens a file

readAsText Reads the content with DOMString(string)

copyTo Copies and overwrites a file or a directory

moveTo Moves and overwrites a file or a directory

createDirectory To create directory

createFile To create empty file

resolve Resolves an existing file or directory relative to the current directory

deleteDirectory To delete Directory/Directory tree

deleteFile To delete File

Page 12: Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface access the Filesystem API •Methods resolve To access the file by Resolving location

Ajou Univrsity

File

• File • Example of File interface

Handling the files through tizen.filesystem.resolve

Line 6 : Reading file name generated by createFile

Line 8 : Show the location by toURI method

Line 12 : Reads i-th file by textmode

Line 17 : Show the number of file in its Directory

Page 13: Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface access the Filesystem API •Methods resolve To access the file by Resolving location

Ajou Univrsity

FileStream

• FileStream • Handling to a File opened for read and write operation interface

• Attributes

The interface Attribute and Method

readonly boolean eof Indicates the file pointer is at the end of the file

long position Indicate the stream position for read or write

readonly long bytesAvailable The number of bytes that are available for reading for the stream

Page 14: Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface access the Filesystem API •Methods resolve To access the file by Resolving location

Ajou Univrsity

FileStream

• FileStream • Methods

close Close File Stream

read Read the specific number of character

readBytes Read the specified number of bytes

write Writes the specified DOMString

writeBytes Writes the specified bytes

Page 15: Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface access the Filesystem API •Methods resolve To access the file by Resolving location

Ajou Univrsity

Filesystem Success Callback

Page 16: Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface access the Filesystem API •Methods resolve To access the file by Resolving location

Ajou Univrsity

FileSuccessCallback

• FileSuccessCallback • File object’s input argument is a property when the success is

done

• Because of asynchronous operation, the callback function is written in advance

• Asynchronous call Success

FileSuccessCallback interface and parameter

• File from Asynchronous call

Page 17: Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface access the Filesystem API •Methods resolve To access the file by Resolving location

Ajou Univrsity

FileSystemStorageArraySuccessCallback

• FileSystemStorageArraySuccessCallback • FileSystem Storage object’s input argument is a property when the

success is done • In Array of FileSystemStorage object Call back

• Because of asynchronous operation, the callback function is written in advance

• Asynchronous call Success

FileSystemStorageArraySuccessCallback interface and parameter

• The list of available device

Page 18: Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface access the Filesystem API •Methods resolve To access the file by Resolving location

Ajou Univrsity

FileSystemStorageSuccessCallback

• FileSystemStorageSuccessCallback • FileSystem Storage object’s input argument is a property when the

success is done • In Array of FileSystemStorage object Call back

• Because of asynchronous operation, the callback function is written in advance

• Asynchronous call Success

FileSystemStorageSuccessCallback interface and parameter

• Storage Device Structure

Page 19: Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface access the Filesystem API •Methods resolve To access the file by Resolving location

Ajou Univrsity

FileStringSuccessCallback

• FileStringSuccessCallback • Read the DOMString file content

• DOMString object is input argument and Call back

• Asynchronous operation

• Asynchronous call Success

FileStringSuccessCallback interface and parameter

• The file represented as a DOMString

Page 20: Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface access the Filesystem API •Methods resolve To access the file by Resolving location

Ajou Univrsity

FileStreamSuccessCallback

• FileStreamSuccessCallback • This interface is opening the File

• FileStream object is input argument and Call back

• Asynchronous operation

• Asynchronous call Success

FileStringSuccessCallback interface and parameter

• The filestream to access file content