From 3fa108400b5bf98d9191ea6f3d92406310408cea Mon Sep 17 00:00:00 2001 From: Arkadiusz Pietraszek Date: Mon, 8 Jan 2018 16:23:33 +0100 Subject: [PATCH] [Filesystem] Fix to commit ce958812096 to read 64 Kb and greater files 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 | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/filesystem/js/file.js b/src/filesystem/js/file.js index 84248264..a55531d5 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.34.1