[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

api[www,FileAPIDS] code

NativeObject
	subclass: #FileAPIDSObject
	category: #FileAPIDS!
FileAPIDSObject comment: '
	Provides  an API to navigate file system hierarchies, and defines a means by which a user agent may expose sandboxed sections of a users local filesystem to web applications.
	http://www.w3.org/TR/file-system-api/
	@2013 Alejandro Reimondo [email protected]
'!

#(	#LocalFileSystem #LocalFileSystemSync #Metadata
	#FileSystem #Entry #DirectoryReader 
	#FileSystemSync #EntrySync #DirectoryReaderSync 
	#FileSystemCallback #EntryCallback #EntriesCallback 
	#MetadataCallback #FileWriterCallback #FileCallback 
	#VoidCallback #ErrorCallback 
) do: [:each| FileAPIDSObject subclass: each ].!

Entry subclass: #DirectoryEntry!
Entry subclass: #FileEntry!
EntrySync subclass: #DirectoryEntrySync!
EntrySync subclass: #FileEntrySync!

! BrowserWindow methodsFor: 'FileAPIDS-converting' !
asLocalFileSystem
	" Return the receiver adapted to LocalFileSystem interface.  "

	^LocalFileSystem @ self handle! !

LocalFileSystem buildFunctions: #(
	#( #requestFileSystem:size:successCallback:errorCallback:
		#( #type #size #successCallback #errorCallback ) )
	#( #requestFileSystem:size:successCallback:
		#( #type #size #successCallback ) )
	#( #resolveLocalFileSystemURL:successCallback:errorCallback:
		#( #url #successCallback #errorCallback ) )
	#( #resolveLocalFileSystemURL:successCallback:
		#( #url #successCallback ) )
)!

! LocalFileSystem class methodsFor: #constants !
temporary
	" Return the constant value TEMPORARY "

	^0! !

! LocalFileSystem class methodsFor: #constants !
persistent
	" Return the constant value PERSISTENT "

	^1! !

LocalFileSystemSync buildFunctions: #(
	#( #requestFileSystemSync:size: #( #type #size ) )
	#( #resolveLocalFileSystemSyncURL: #( #url ) )
)!

! LocalFileSystemSync class methodsFor: #constants !
temporary
	" Return the constant value TEMPORARY "

	^0! !

! LocalFileSystemSync class methodsFor: #constants !
persistent
	" Return the constant value PERSISTENT "

	^1! !

Metadata buildGetters: #( #modificationTime #size )!
FileSystem buildGetters: #( #name #root )!
Entry buildBooleanGetters: #( #isFile #isDirectory )!
Entry buildGetters: #( #name #fullPath #filesystem )!
Entry buildFunctions: #(
	#( #getMetadata:errorCallback: #( #successCallback #errorCallback ) )
	#( #getMetadata: #( #successCallback ) )
	#( #moveTo:newName:successCallback:errorCallback:
		#( #parent #newName #successCallback #errorCallback ) )
	#( #moveTo:newName:successCallback: #( #parent #newName #successCallback ) )
	#( #moveTo:newName: #( #parent #newName ) )
	#( #moveTo: #( #parent ) )
	#( #copyTo:newName:successCallback:errorCallback:
		#( #parent #newName #successCallback #errorCallback ) )
	#( #copyTo:newName:successCallback: #( #parent #newName #successCallback ) )
	#( #copyTo:newName: #( #parent #newName ) )
	#( #copyTo: #( #parent ) )
	#toURL
	#( #remove:errorCallback: #( #successCallback #errorCallback ) )
	#( #remove: #( #successCallback ) )
	#( #getParent:errorCallback: #( #successCallback #errorCallback ) )
	#( #getParent: #( #successCallback ) )
)!

DirectoryEntry buildFunctions: #(
	#createReader
	#( #getFile:options:successCallback:errorCallback:
		#( #path #options #successCallback #errorCallback ) )
	#( #getFile:options:successCallback: #( #path #options #successCallback ) )
	#( #getFile:options: #( #path #options ) )
	#( #getFile: #( #path ) )
	#( #getDirectory:options:successCallback:errorCallback:
		#( #path #options #successCallback #errorCallback ) )
	#( #getDirectory:options:successCallback: #( #path #options #successCallback ) )
	#( #getDirectory:options: #( #path #options ) )
	#( #getDirectory: #( #path ) )
	#( #removeRecursively:errorCallback: #( #successCallback #errorCallback ) )
	#( #removeRecursively: #( #successCallback ) )
)!

DirectoryReader buildFunctions: #(
	#( #readEntries:errorCallback: #( #successCallback #errorCallback ) ) 
	#( #readEntries: #( #successCallback ) ) 
)!

FileEntry buildFunctions: #(
	#( #createWriter:errorCallback: #( #successCallback #errorCallback ) )
	#( #createWriter: #( #successCallback ) )
	#( #file:errorCallback: #( #successCallback #errorCallback ) )
	#( #file: #( #successCallback ) )
)!

FileSystemCallback buildFunctions: #( #( #handleEvent: #( #filesystem ) ) )!
EntryCallback buildFunctions: #( #( #handleEvent: #( #entry ) ) )!
EntriesCallback buildFunctions: #( #( #handleEvent: #( #entries ) ) )!
MetadataCallback buildFunctions: #( #( #handleEvent: #( #metadata ) ) )!
FileWriterCallback buildFunctions: #( #( #handleEvent: #( #fileWriter ) ) )!
FileCallback buildFunctions: #( #( #handleEvent: #( #file ) ) )!
VoidCallback buildFunctions: #( #( #handleEvent #() ) )!
ErrorCallback buildFunctions: #( #( #handleEvent: #( #err ) ) )!
FileSystemSync buildGetters: #( #name #root )!

EntrySync buildBooleanGetters: #( #isFile #isDirectory )!
EntrySync buildGetters: #( #name #fullPath #filesystem )!

EntrySync buildFunctions: #(
	#getMetadata
	#( #moveTo:newName: #( #parent #newName ) )
	#( #copyTo:newName: #( #parent #newName ) )
	#toURL
	#remove
	#getParent
)!

DirectoryEntrySync buildFunctions: #(
	#createReader
	#( #getFile:options: #( #path #options ) )
	#( #getDirectory:options: #( #path #options ) )
	#removeRecursively
)!

DirectoryReaderSync buildFunctions: #( #readEntries )!
FileEntrySync buildFunctions: #(
	#createWriter
	#file
)!