Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-8580

BlackBerry: Implement important Titanium.Filesystem functionality

    Details

    • Story Points:
      17

      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());
      }
      

        Attachments

          Activity

            People

            • Assignee:
              penrique Pedro Enrique (Inactive)
              Reporter:
              fboisvert Francois Boisvert
              Reviewer:
              Josh Roesslein
            • Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Integration