[TIMOB-5034] Ti.File.setReadonly() does nothing on iOS and throws an error on Android
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2017-08-08T18:33:54.000+0000 |
Affected Version/s | Release 1.7.2 |
Fix Version/s | n/a |
Components | n/a |
Labels | android, defect, ios |
Reporter | Tim Poulsen |
Assignee | Ingo Muschenetz |
Created | 2011-08-17T11:29:55.000+0000 |
Updated | 2017-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]
Closing due to inactivity. If this issue still exists, please raise a new ticket. To add, the associated URL is no longer valid.