Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface...
Transcript of Tizen - Web Application · Ajou Univrsity FilesystemManager •FilesystemManager •The interface...
Tizen - Web Application
Input/Output Filesystem API
Ajou Univrsity
Contents
• Filesystem API
• Interfaces of Filesystem API
• Filesystem Success Callback
Ajou Univrsity
Filesystem API
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
Ajou Univrsity
Interface of Filesystem API
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
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
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)
Ajou Univrsity
File
• File • The interface of File abstraction (According to isFile property)
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
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
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
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
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
Ajou Univrsity
Filesystem Success Callback
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
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
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
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
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