[TIMOB-4486] Filesystem API does not work
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Invalid |
| Resolution Date | 2011-06-23T11:10:00.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | n/a |
| Labels | n/a |
| Reporter | Igor Kucheinyk |
| Assignee | Eric Merriman |
| Created | 2011-06-23T01:37:01.000+0000 |
| Updated | 2014-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
| File | Date | Size |
|---|---|---|
| screen.PNG | 2011-06-23T01:37:01.000+0000 | 89866 |
| Screen shot 2011-06-23 at 10.38.52 AM.png | 2011-06-23T01:37:01.000+0000 | 592094 |
Hello Igor, You can't write to the resources directory. It's read-only. We'll discuss via email.