Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3524] Android: Ti.Filesystem.File.createFile() does not exist

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2017-05-02T21:47:41.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsandroid, defect
ReporterPaul Dowsett
AssigneeIngo Muschenetz
Created2011-04-15T03:46:16.000+0000
Updated2017-05-02T21:47:41.000+0000

Description

Environment:

  • Android emulator 2.2
  • Ti 1.5.2 (11 Jan 2011) and 1.6.1 (15 Mar 2011)

Although the createFile() method is documented in http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Filesystem.File-object"> Titanium.Filesystem.File, no code exists for it in the Titanium Android SDK source, at https://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/org/appcelerator/titanium/io/TiBaseFile.java"> TiBaseFile.java. Furthermore, no demonstration of its usage exists in https://github.com/appcelerator/titanium_mobile/blob/master/demos/KitchenSink/Resources/examples/filesystem.js"> filesystem.js.

The workaround is to use the write() method instead, but unless a string is passed to it (even and empty one like write("") ) then the file is not created.

The following code demonstrates the issue:

var newDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'html');
Ti.API.info("newDir.nativePath = " + newDir.nativePath);

newDir.createDirectory();

var fileTest = Ti.Filesystem.getFile(newDir.nativePath,'test.html');
fileTest.deleteFile();
Ti.API.info("test.html exists before write()? " + fileTest.exists());
fileTest.write();
Ti.API.info("test.html exists after write()? " + fileTest.exists());
fileTest.write('');
Ti.API.info("test.html exists after write('')? " + fileTest.exists());

Proposed solution:

  • remove createFile() from API docs
  • allow write() method to accept no argument, in order to create an empty file

Note that depending on the chosen solution, obviously the tags used in this ticket may be incorrect, and another ticket may need to raised.

Comments

  1. Lee Morris 2017-05-02

    Resolving ticket as Invalid as there is now a new version of Kitchen Sink available and we no longer support the version which relates to this ticket.

JSON Source