[Filesystem] Fix to commit 50ec63f0b8 to read 64 Kb and greater files 89/166189/2
authorArkadiusz Pietraszek <a.pietraszek@partner.samsung.com>
Mon, 8 Jan 2018 15:52:30 +0000 (16:52 +0100)
committerArkadiusz Pietraszek <a.pietraszek@partner.samsung.com>
Tue, 9 Jan 2018 10:43:16 +0000 (11:43 +0100)
[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

Commit 50ec63f0b8 has introduced error in which only first 64 Kb of
text file was read.

Change-Id: I679cb4a6447c6996a882388c304989e14f6ec6be

src/filesystem/js/file.js

index 8424826..44d5487 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);
   }