Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4486] Filesystem API does not work

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionInvalid
Resolution Date2011-06-23T11:10:00.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterIgor Kucheinyk
AssigneeEric Merriman
Created2011-06-23T01:37:01.000+0000
Updated2014-06-19T12:46:31.000+0000

Description

I've created simple app in Titanium Studio that failed to run on emulator and device, see attached screenshots.
// Create test folder
var suitesDir = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, 'testdata');
if(!suitesDir.exists()) {
	suitesDir.createDirectory();
	alert('suites dir created');
}
var testDir = Titanium.Filesystem.getFile(suitesDir.nativePath, 123);

if(!testDir.exists()) {
	testDir.createDirectory();
	alert('test dir created');
}

// Delete everything from this dir
var file;
var files = testDir.getDirectoryListing();
for(var ii=files.length-1; ii>=0; ii--) {
    file = Titanium.Filesystem.getFile(testDir.nativePath, files[ii]);
    file.deleteFile();
}

var testImplementation = 'alert("test");';
// Write implementation to the file
var newFile = Titanium.Filesystem.getFile(testDir.nativePath, 'test.js');
if(newFile.write(testImplementation)) {
    alert('write ok');
} else {
    alert('couldnt write file');
}

Attachments

FileDateSize
screen.PNG2011-06-23T01:37:01.000+000089866
Screen shot 2011-06-23 at 10.38.52 AM.png2011-06-23T01:37:01.000+0000592094

Comments

  1. Eric Merriman 2011-06-23

    Hello Igor, You can't write to the resources directory. It's read-only. We'll discuss via email.

JSON Source