Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16445] Anvil: issues using Ti.Filesystem.getFile

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Fix
Resolution Date2017-05-22T21:21:46.000+0000
Affected Version/sRelease 3.2.1
Fix Version/sn/a
Componentsn/a
Labelslinvalid
ReporterFederico Casali
AssigneeEric Merriman
Created2014-02-11T19:57:55.000+0000
Updated2017-05-22T22:09:58.000+0000

Description

Problem description

Using Anvil for SyncServer testing, an issue is surfacing when using Ti.Filesystem.getFile for checking folder. Attached sample code run manually on device works as expected. See lines 153 to 170 of the attached sample code 'app.js':
 function copyfiles(){
        var srcDataDir = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "myfiles");
        var destDataDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "myfiles");
        destDataDir.createDirectory();
        var files = srcDataDir.getDirectoryListing();
        var qty = files.length;
        Ti.API.info('#### qty: ' + JSON.stringify(qty));
        for(var i = 0; i < (qty-1); i++) {
            var srcFile = Ti.Filesystem.getFile(srcDataDir.nativePath, files[i]);
            var destFile = Ti.Filesystem.getFile(destDataDir.nativePath, files[i]);
            destFile.write(srcFile.read());

            if (!destFile.exists()) {
            	 alert(destFile.nativePath);
            };
        }
    }
When run on device, it works as expected (destFile.exists() returns true). However, running the same code on Anvil and adding a valueOf check:
valueOf(testRun,destFile.exists()).shouldBeTrue();
is returning false, thus an error. 'externalfilesync.js' file attached is the Anvil test sample - see 'function copyfiles()' line 214.

Comments

  1. Lee Morris 2017-05-22

    Anvil is no longer supported, this ticket is now irrelevant.

JSON Source