[TIMOB-23493] Android: Support #append() method on Ti.Filesystem.File
| GitHub Issue | n/a |
|---|---|
| Type | Improvement |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2016-11-15T22:03:12.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 6.1.0 |
| Components | Android |
| Labels | parity |
| Reporter | Christopher Williams |
| Assignee | Farzad Merzadyan |
| Created | 2016-06-10T18:57:37.000+0000 |
| Updated | 2016-11-22T22:03:45.000+0000 |
Description
Android is the only platform that doesn't support Ti.Filesystem.File#append(). We should ideally support it for parity's sake.
PR: https://github.com/appcelerator/titanium_mobile/pull/8513 *epected result if firstFile is already existing else should return true for first line of log output* {noformat} ? I/TiAPI: firstFile status: createdFile: false ? I/TiAPI: firstFile status: appended_lorem: true ? I/TiAPI: secondFile status: appended_theory: true ? I/TiAPI: firstFile status: appended_file_to_file: true ? I/TiAPI: firstBlobFile status: appended_blob: true {noformat} *test code:*
var window = Ti.UI.createWindow({ backgroundColor: 'white' }); window.open(); var firstFile = null; var lorem_ipsum = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."; var theory_of_science = "In theoretical computer science and mathematics, the theory of computation is the branch that deals with how efficiently problems can be solved on a model of computation, using an algorithm. The field is divided into three major branches: automata theory and language, computability theory, and computational complexity theory, which are linked by the question: 'What are the fundamental capabilities and limitations of computers?'.[1]"; try { // get firstFile handle firstFile = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "first_file"); try { var createdFile = firstFile.createFile(); Ti.API.info("firstFile status: createdFile: " + createdFile); var appended_lorem = firstFile.append(lorem_ipsum); Ti.API.info("firstFile status: appended_lorem: " + appended_lorem); // var deletedFile = firstFile.deleteFile(); // Ti.API.info("firstFile status: deletedFile: " + deletedFile); var secondFile = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "second_file"); secondFile.createFile(); var appended_theory = secondFile.append(theory_of_science); Ti.API.info("secondFile status: appended_theory: " + appended_theory); /** * APPEND FILE TO FILE TEST */ var appended_file_to_file = firstFile.append(secondFile); Ti.API.info("firstFile status: appended_file_to_file: " + appended_file_to_file); /** * APPEND BLOB FILE TO BLOB FILE TEST */ var firstBlobFile = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "first_blob_file"); firstBlobFile.createFile(); firstBlobFile.append(firstFile.read()); var secondBlobFile = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "second_blob_file"); secondBlobFile.createFile(); secondBlobFile.append(secondFile.read()); var appended_blob = firstBlobFile.append(secondBlobFile); Ti.API.info("firstBlobFile status: appended_blob: " + appended_blob); } catch (err) { Ti.API.error("firstFile error. directory listing: " + firstFile.getDirectoryListing.toString() + " file: " + firstFile.resolve() + " " + err); } } catch (err) { Ti.API.error("firstFile error. " + err); }Verified, fixed was able to view the following comments in the console.
*Environment*