Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12742] Android/iOS: Ti.Filesystem.Filestream.isWriteable() doesn't work properly

GitHub Issuen/a
TypeBug
Priorityn/a
StatusReopened
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsTiAPI
Labelsandroid, iOS
ReporterCarter Lathrop
AssigneeUnknown
Created2013-02-12T18:26:48.000+0000
Updated2018-02-28T20:03:20.000+0000

Description

*Problem* Bug description: Ti.Filesystem.Filestream.isWriteable() gives error in Android & iOS. *Steps to reproduce:* 1. copy and paste test code below into app.js 2. add attached file.txt to Resources folder 3. run code on device in android 4. click isReadable button, notice it works and returns boolean value true 5. click isWriteable button, notice error when it should return boolean value false 6. repeat steps on iOS simulator to see similar result *Expected Behavior* isWriteable should return false *Actual Behavior* isWritable throws error *Code example:*
var win = Ti.UI.createWindow({
	backgroundColor : 'black'
});

var button1 = Ti.UI.createButton({
	top : 10,
	title : 'isReadable?'
});

var button2 = Ti.UI.createButton({
	top : 100,
	title : 'isWritable?'
});

button1.addEventListener('click', function(e) {
	var infile = Titanium.Filesystem.getFile('file.txt');
	if (!infile.exists()) {
		Ti.API.error("File not exists()");
		return;
	}
	var instream = infile.open(Titanium.Filesystem.MODE_READ);

	var isReadable = instream.isReadable();

	alert('Is readable = ' + isReadable);
});

button2.addEventListener('click', function(e) {
	var infile = Titanium.Filesystem.getFile('file.txt');
	if (!infile.exists()) {
		Ti.API.error("File not exists()");
		return;
	}
	var instream = infile.open(Titanium.Filesystem.MODE_READ);

	var isWriteable = instream.isWriteable();

	alert('Is writeable = ' + isWriteable);
});

win.add(button1);
win.add(button2);

win.open();

Attachments

FileDateSize
file.txt2013-02-14T22:15:22.000+000011
FileStreamSample.zip2013-02-14T11:52:02.000+0000755338

Comments

  1. Carter Lathrop 2013-02-13

    Hello Roman, Would you mind providing a reproducible piece of test code that once could just paste into a project and run to produce the bug? This way I can reproduce exactly what you are trying and determine if it should be moved to engineering from there. Thank you, Carter
  2. Roman Kamenetsky 2013-02-14

    Hello Carter, I attached the test project. Just run it. Regards, Roman
  3. Carter Lathrop 2013-02-14

    Roman, I was able to recreate your bug so I will be moving this to Ti-Mobile and engineering will take a look at it. I have created my own test case though so that the error is more visible. Please keep a watch on the ticket and thank you for bringing this to our attention. Best, Carter

JSON Source