Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12901] Android: Ti.FileSystemProxy interprets resourceDir as a File

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-03-27T18:14:07.000+0000
Affected Version/sRelease 3.1.0
Fix Version/sRelease 3.1.0, 2013 Sprint 07 API, 2013 Sprint 07
ComponentsAndroid
Labelsfilesystem, qe-sdk3.1.0, qe-testadded
ReporterOlga Romero
AssigneePing Wang
Created2013-03-01T00:31:54.000+0000
Updated2013-03-27T18:14:07.000+0000

Description

While testing New iOS feature for parity with Android I noticed that resources "Directory" is interpreted as a "File" on Android. Test steps: 1.Run the following code
/*jslint maxerr:1000 */
 
//Test if the resources folder is a directory.
var resourceDir = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory);
Ti.API.info('resourceDir ' + resourceDir);
Ti.API.info('resourceDir nativePath ' + resourceDir.nativePath);
Ti.API.info('resourceDir isDirectory ' + resourceDir.isDirectory());
Ti.API.info('resourceDir isFile ' + resourceDir.isFile());
 
 
var newDir = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,'mydir');
if(!newDir.exists()){
  Ti.API.info("Created mydir: " + newDir.createDirectory());  
}
 
var newFile = Titanium.Filesystem.getFile(newDir.nativePath,'newfile.txt');
newFile.write("\nText appended via write()", true);
 
Ti.API.info('newdir ' + newDir);
Ti.API.info('newdir nativePath ' + newDir.nativePath);
Ti.API.info('newdir isDirectory ' + newDir.isDirectory());
Ti.API.info('newdir isFile ' + newDir.isFile());
 
 
Ti.API.info('newFile ' + newFile);
Ti.API.info('newFile nativePath ' + newFile.nativePath);
Ti.API.info('newFile isDirectory ' + newFile.isDirectory());
Ti.API.info('newFile isFile ' + newFile.isFile());

Ti.API.info('End Test');

Ti.API.info('Now open a window so we can test on device easier');
 
// Create a simple window to show our results
(function(){
	
	var win = Ti.UI.createWindow({
		backgroundColor:'#fff',layout:'vertical'
	});
 
	win.add(Ti.UI.createLabel({
		top:10, text:'resourceDir isDirectory ' + resourceDir.isDirectory()
	}));
	
	win.add(Ti.UI.createLabel({
		top:10, text:'resourceDir isFile ' + resourceDir.isFile()
	}));
		
	win.add(Ti.UI.createLabel({
		top:10, text:'newdir isDirectory ' + newDir.isDirectory()
	}));
	
	win.add(Ti.UI.createLabel({
		top:10, text:'newdir isFile ' + newDir.isFile()
	}));
 
	win.add(Ti.UI.createLabel({
		top:10, text:'newFile isDirectory ' + newFile.isDirectory()
	}));
	
	win.add(Ti.UI.createLabel({
		top:10, text:'newFile isFile ' + newFile.isFile()
	}));
 
					
	win.open();	
	
})();
 
Actual result: Android - resourceDir isFile true iOS - resourceDir isFile false Expected: resourceDir isFile false

Attachments

FileDateSize
Android.png2013-03-01T00:31:54.000+000031681
iPhone.png2013-03-01T00:31:54.000+000050385
logcat.txt2013-03-01T00:31:54.000+0000784

Comments

  1. Ping Wang 2013-03-26

    PR: https://github.com/appcelerator/titanium_mobile/pull/4032
  2. Olga Romero 2013-03-27

    Tested and verified fix with: Titanium Studio, build: 3.1.0.201303261815 Titanium SDK, build: 3.1.0.v20130327075056 Device: Nexus7 Android version 4.2
  3. Olga Romero 2013-03-27

    reopened to correct comment

JSON Source