Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23493] Android: Support #append() method on Ti.Filesystem.File

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-11-15T22:03:12.000+0000
Affected Version/sn/a
Fix Version/sRelease 6.1.0
ComponentsAndroid
Labelsparity
ReporterChristopher Williams
AssigneeFarzad Merzadyan
Created2016-06-10T18:57:37.000+0000
Updated2016-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.

Comments

  1. Farzad Merzadyan 2016-10-18

    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);
       }
       
  2. Samir Mohammed 2016-11-22

    Verified, fixed was able to view the following comments in the console.
       [INFO] :   firstFile status: createdFile: false
       [INFO] :   firstFile status: appended_lorem: true
       [INFO] :   secondFile status: appended_theory: true
       [INFO] :   firstFile status: appended_file_to_file: true
       [INFO] :   firstBlobFile status: appended_blob: true
       
    *Environment*
       Appcelerator Command-Line Interface, version 6.0.0
       Android 7.0 (Google Nexus 6P)
       Operating System Name: Mac OS X El Capitan
       Operating System Version: 10.11.6
       Node.js Version: 4.6.0
       npm: 4.2.8
       Titanium CLI Version: 5.0.10
       Titanium SDK Version: 6.1.0.v20161121162514
       Xcode: 8.0
       Appcelerator Studio: 4.8.0.201611121409
       

JSON Source