Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5034] Ti.File.setReadonly() does nothing on iOS and throws an error on Android

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Fix
Resolution Date2017-08-08T18:33:54.000+0000
Affected Version/sRelease 1.7.2
Fix Version/sn/a
Componentsn/a
Labelsandroid, defect, ios
ReporterTim Poulsen
AssigneeIngo Muschenetz
Created2011-08-17T11:29:55.000+0000
Updated2017-08-08T18:33:54.000+0000

Description

Ti.Filesystem.File.setReadonly() fails silently on iOS (simulator) and crashes on Android with the error shown in the code comments below. You can drop the following into a default new TiMobile project to test:
var f = Titanium.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'test.txt');
f.write('Hello World');
Ti.API.info('f exists: '+f.exists()); // = true
Ti.API.info('f contents: '+f.read()); // = Hello World
// setReadonly has no effect on iOS simulator
// On Android -- org.mozilla.javascript.EcmaError: TypeError: Cannot find function setReadonly in object [object TiFileProxy].
f.setReadonly(); 
Ti.API.info('File is read only: '+f.readonly); // = false on iOS
try {
	f.deleteFile();
	Ti.API.info('deleting worked');
	Ti.API.info('f contents =  '+f.read());
} catch(e) {
	alert('Error: '+Ti.API.error);
	alert(e.error);
}
Associate API docs: [http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Filesystem.File.setReadonly-method.html]

Comments

  1. Lee Morris 2017-08-08

    Closing due to inactivity. If this issue still exists, please raise a new ticket. To add, the associated URL is no longer valid.

JSON Source