[Filesystem] Fix to commit ce958812096 to read 64 Kb and greater files 88/166188/2
authorArkadiusz Pietraszek <a.pietraszek@partner.samsung.com>
Mon, 8 Jan 2018 15:23:33 +0000 (16:23 +0100)
committerArkadiusz Pietraszek <a.pietraszek@partner.samsung.com>
Tue, 9 Jan 2018 10:41:34 +0000 (11:41 +0100)
Commit ce958812096 has introduced error in which only first 64 Kb of
text file was read.

[Verification] TCT pass rate is 100%
    Automated tests has been run:
    tct-archive-tizen-tests
    tct-systeminfo-tizen-tests
    tct-content-tizen-tests
    tct-filesystem-tizen-tests

Change-Id: I266c839e78af9420bdad328e8fa4332bdc16b8a4

src/filesystem/js/file.js

index 84248264a07a6e05e2f1c1c8892a7724c58c7d90..a55531d53ce026069837d35e1415d2e6bd1f36a7 100644 (file)
@@ -324,20 +324,24 @@ function readAsText() {
   function readFile() {
     var result, encoded, buffers = [];
 
-    result = native_.callSync('File_readSync', data);
-    if (native_.isFailure(result)) {
-      setTimeout(function() {
-        native_.callIfPossible(args.onerror, native_.getErrorObject(result));
-      }, 0);
-      return;
-    }
-    result = native_.getResultObject(result);
-    if (result.length) {
-      data.offset += data.length;
-    }
+    var output = "";
+    do {
+      result = native_.callSync('File_readSync', data);
+      if (native_.isFailure(result)) {
+        setTimeout(function() {
+          native_.callIfPossible(args.onerror, native_.getErrorObject(result));
+        }, 0);
+        return;
+      }
+      result = native_.getResultObject(result);
+      if (result.length) {
+        data.offset += data.length;
+      }
+      output = output + result;
+    } while (result.length);
 
     setTimeout(function() {
-      native_.callIfPossible(args.onsuccess, result);
+      native_.callIfPossible(args.onsuccess, output);
     }, 0);
   }