Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25683] iOS: Address Ti.Filesystem parity issues, refactor Ti.Filesystem API's, fix broken tests

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusClosed
ResolutionDuplicate
Resolution Date2018-05-09T10:43:50.000+0000
Affected Version/sRelease 7.0.1
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterHans Knöchel
AssigneeHans Knöchel
Created2018-01-18T13:11:57.000+0000
Updated2018-08-06T17:41:11.000+0000

Description

There are a couple of Ti.Filesystem.File API's that are not available on iOS according to the documentation: * copy(newPath) * readonly * parent Also, some unit-tests are not working because: * createTimestamp() and modificationTimestamp() return a different value (Date) than they should (Number) * File-errors are muted, they should be logged on the error-level and the method should continue as before (no breaking change) * Return types are id instead of their proper type (TiBlob, TiFile, NSString, NSNumber). Not a biggie, but may look confusing to contributors While copy() was not available so far, the properties readonly and parent already but haven't been documented to be available.

Comments

  1. Hans Knöchel 2018-01-18

    PR: https://github.com/appcelerator/titanium_mobile/pull/9750 Test-Case:
       var win = Ti.UI.createWindow({
           backgroundColor: '#fff'
       });
       
       var btn = Ti.UI.createButton({
         title: 'Trigger'
       });
       
       btn.addEventListener('click', function() {
         
         // Hey there! Comment in the tests after each other and compare the results
         
         // testRecursiveDirectories();
         // testCreateTimestamp();
         // testModificationTimestamp();
       })
       
       function testRecursiveDirectories() {
         var dir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'sub');
         
         Ti.API.info('Path: ' + dir.nativePath);
         
         // Should not exist
         if (dir.exists()) {
           Ti.API.error('#1 failed!');
         }
         
         // Should succeed
         if (!dir.createDirectory()) {
           Ti.API.error('#2 failed!');
         }
         
         // Should exist
         if (!dir.exists()) {
           Ti.API.error('#3 failed!');
         }
         
         // Should succeed
         if (!dir.deleteDirectory()) {
           Ti.API.error('#4 failed!');
         }
         
         // Should not exist
         if (dir.exists()) {
           Ti.API.error('#5 failed!');
         }
       }
       
       function testCreateTimestamp() {
         var file = Ti.Filesystem.getFile('app.js');
         var create_date = file.createTimestamp();
         
         // Should be a number (Double)
         Ti.API.info(create_date);
       }
       
       function testModificationTimestamp() {
         var file = Ti.Filesystem.getFile('app.js');
         var mod_date = file.modificationTimestamp();
         
         // Should be a number (Double)
         Ti.API.info(mod_date);
       }
       
       win.add(btn);
       win.open();
       
  2. Hans Knöchel 2018-05-09

    Resolved as part of TIMOB-26025
  3. Eric Merriman 2018-08-06

    Closing as a duplicate. If this is in error, please reopen.

JSON Source