Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8580] BlackBerry: Implement important Titanium.Filesystem functionality

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-05-17T22:30:00.000+0000
Affected Version/sn/a
Fix Version/s2013 Sprint 10 BB, 2013 Sprint 10, Release 3.1.2, Release 3.2.0
ComponentsBlackBerry
Labelsmodule_filesystem, notable, qe-testadded
ReporterFrancois Boisvert
AssigneePedro Enrique
Created2012-04-06T06:35:46.000+0000
Updated2013-10-25T07:04:51.000+0000

Description

* Titanium.Filesystem * Titanium.Filesystem.applicationDataDirectory * Titanium.Filesystem.File * Titanium.Filesystem.File.append * Titanium.Filesystem.File.createDirectory * Titanium.Filesystem.File.deleteFile * Titanium.Filesystem.File.exists * Titanium.Filesystem.File.getNativePath * Titanium.Filesystem.File.nativePath * Titanium.Filesystem.File.read * Titanium.Filesystem.File.writable * Titanium.Filesystem.File.write * Titanium.Filesystem.getFile * Titanium.Filesystem.resourcesDirectory * Titanium.Filesystem.tempDirectory

Test code:

Reading a file from the Resources dir
Ti.API.info('------------------------');
Ti.API.info('Testing resources directory reading app.js');
var app_js = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, 'app.js');
var blob = app_js.read();
Ti.API.info('---------');
Ti.API.info(blob.text);
Creating, writing, and reading a file from the data dir
Ti.API.info('------------------------');
Ti.API.info('Testing data directory reading writing and reading');
var file = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'hello_world.txt');
if(!file.exists()) {
	Ti.API.info('file does not exist');
	file.write('this is a test');
	Ti.API.info('file exists? ' + file.exists());
}
Ti.API.info('---------');
var blob = file.read();
Ti.API.info(blob.text);
Getting the directory listing from the data dir
Ti.API.info('------------------------');
Ti.API.info('Testing data directory get listing');
var directory = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory);
var files = directory.getDirectoryListing();
for(var i = 0; i < files.length; i++) {
	Ti.API.info('=====================');
	var file = files[i];
	Ti.API.info('filename: ' + file);
	var _file = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, file);
	Ti.API.info('isDirectory: ' + _file.isDirectory());
	Ti.API.info('isFile: ' + _file.isFile());
}

Comments

  1. Josh Roesslein 2013-01-31

    Can we deliver all FS APIs in those 4 days? Otherwise I think we need to define what features this ticket will implement in this sprint. It might be good to break up FS into two passes: 1. Querying file information / basic reading/writing (Ti.File). 2. File streams (Ti.FileStream).
  2. Pedro Enrique 2013-05-17

    PR: https://github.com/appcelerator/titanium_mobile_blackberry/pull/39
  3. Priya Agarwal 2013-10-25

    Verified the fix: Tested Environment: Appcelerator Studio: 3.2.0.201310230601 SDK:3.2.0.v20131024120843 alloy: 1.2.2 acs: 1.0.7 npm: 1.3.2 titanium: 3.2.0 titanium-code-processor: 1.0.3 Device:Blackberry Z10(v 10.0) OS: OSX 10.9 Used above specified code. Working fine.

JSON Source