[TIMOB-25683] iOS: Address Ti.Filesystem parity issues, refactor Ti.Filesystem API's, fix broken tests
| GitHub Issue | n/a |
|---|---|
| Type | Improvement |
| Priority | Medium |
| Status | Closed |
| Resolution | Duplicate |
| Resolution Date | 2018-05-09T10:43:50.000+0000 |
| Affected Version/s | Release 7.0.1 |
| Fix Version/s | n/a |
| Components | iOS |
| Labels | n/a |
| Reporter | Hans Knöchel |
| Assignee | Hans Knöchel |
| Created | 2018-01-18T13:11:57.000+0000 |
| Updated | 2018-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.
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();Resolved as part of TIMOB-26025
Closing as a duplicate. If this is in error, please reopen.