[Filesystem] Allow to resolve storages
authorPrzemyslaw Ciezkowski <p.ciezkowski@samsung.com>
Wed, 10 Jun 2015 10:37:18 +0000 (12:37 +0200)
committerPrzemyslaw Ciezkowski <p.ciezkowski@samsung.com>
Fri, 19 Jun 2015 14:25:04 +0000 (23:25 +0900)
Current implementation doesn't allow to
resolve storages.
Without this commit nothing happens when resolving
storage.

[Verification]
Run this code with sdcard attached:
tizen.resolve("removable1", function(dir) {
  console.log("Resolved, full path: " + dir.fullPath);
}, function(e) {
  console.log("Error: " + e.message);
}, "r");
TCT pass rate doesn't change:
TV: 1 Fail
Mobile: 100%

Change-Id: Id0f6326d6a4fad32e9ce691c3b56fa2ac5396f5e
Signed-off-by: Przemyslaw Ciezkowski <p.ciezkowski@samsung.com>
src/filesystem/js/common.js
src/filesystem/js/file_system_manager.js

index 1fe845d06452a53c618613cc900daf9b81c13d97..cae012c32efa125fdce377cdb31d142ca7429aa0 100755 (executable)
@@ -83,6 +83,7 @@ var commonFS_ = (function() {
     var storages = native_.getResultObject(result);
     for (var i = 0; i < storages.length; ++i) {
       cacheStorages.push({
+        path: storages[i].path,
         label: storages[i].name,
         type: storages[i].type,
         state: storages[i].state,
@@ -126,6 +127,18 @@ var commonFS_ = (function() {
       } else {
         //If path token is not present in cache then it is invalid
         _fileRealPath = undefined;
+        // check storages
+        for (var j = 0; j < cacheStorages.length; ++j) {
+          if (cacheStorages[j].label === _pathTokens[0] && (
+            cacheStorages[j].state === undefined ||
+            cacheStorages[j].state === FileSystemStorageState.MOUNTED)) {
+            _fileRealPath = cacheStorages[j].path;
+            for (var i = 1; i < _pathTokens.length; ++i) {
+              _fileRealPath += '/' + _pathTokens[i];
+            }
+            break;
+          }
+        }
       }
     } else {
       _fileRealPath = aPath;
index d883a2fd5267fccdd4e33b6eff1eff5276ff783e..0596075448e454179bfa0cd2b01eef28bdf45a7d 100755 (executable)
@@ -83,7 +83,10 @@ FileSystemManager.prototype.resolve = function(location, onsuccess, onerror, mod
     }
   };
 
-  native_.call('File_stat', data, callback);
+  var ret = native_.call('File_stat', data, callback);
+  if (native_.isFailure(ret)) {
+      throw native_.getErrorObject(ret);
+  }
 };
 
 FileSystemManager.prototype.getStorage = function(label, onsuccess, onerror) {