From 1317b60a1bf584a321f15883f3a8680e2338cb71 Mon Sep 17 00:00:00 2001 From: Arkadiusz Pietraszek Date: Mon, 8 Jan 2018 16:52:30 +0100 Subject: [PATCH] [Filesystem] Fix to commit 50ec63f0b8 to read 64 Kb and greater files [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 | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/filesystem/js/file.js b/src/filesystem/js/file.js index 8424826..44d5487 100644 --- a/src/filesystem/js/file.js +++ b/src/filesystem/js/file.js @@ -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); } -- 2.7.4