maccman/macgap — pull request #25 by liamks (2012-01-29 22:52:43+00:00)
Title: Added File Access

With this commit, developers will not be able to get a list of the absolute paths of files after a user has selected files from `` or from drag and drop. With those absolute file paths text from the file, or a base64 representation of the file can be obtained (useful for images).

Design decisions:
WebKit's implementation of the File API is over 8,000 lines of C++ code and includes many dependencies. Fully implementing this would be extensive work. I reasoned that the most important thing, was a text representation and the base64 representation of a file. The code in this commit allows one to get those values. The File API includes the ability to get the Binary representation of a file, that can always be added later.

In the File API a base64 file is prefixed with its mime type. Mac OS X uses Uniform Type Identifiers (UTIs). I've thus added code that translate UTIs of images to mimetypes. It seems though that the base64 encoding of an image can still be displayed without the mimetype.

In the File API file access is asynchronous with events associated with the completion of a file reading. I wasn't able to get that to work unfortunately! However, I think someone with more Objective-c/WebKit experience could take this code and add that functionality. In the mean time I think this is usable.

Please test this first!!!