From: Andrzej Popowski Date: Tue, 4 Oct 2016 09:43:00 +0000 (+0200) Subject: [Filesystem] - update position and eof attributes of fileStream in read X-Git-Tag: submit/tizen/20161004.110359~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4e08b69e81ae37ac18b6c60e7e50a6b6a4b9b4e8;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Filesystem] - update position and eof attributes of fileStream in read [Verification] - TCT results 100% Change-Id: If03b99e8b3ef0619f981353a096c1c5c414cabc8 Signed-off-by: Andrzej Popowski --- diff --git a/src/filesystem/js/file_stream.js b/src/filesystem/js/file_stream.js index 2036254b..2abc68ff 100644 --- a/src/filesystem/js/file_stream.js +++ b/src/filesystem/js/file_stream.js @@ -134,9 +134,17 @@ function read() { if (native_.isFailure(result)) { throw new WebAPIException(WebAPIException.IO_ERR, 'Could not read'); } - var encoded = native_.getResultObject(result); + var decoded = Base64.decodeString(native_.getResultObject(result)); + + if (decoded.length) { + can_change_size = true; + this.position += decoded.length; + can_change_size = false; + } else { + this.position += 1; // Set EOF + } - return Base64.decodeString(encoded); + return decoded; }; FileStream.prototype.read = function() { @@ -171,9 +179,18 @@ function readBytes() { if (native_.isFailure(result)) { throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Could not read'); } - var encoded = native_.getResultObject(result); - return Base64.decode(encoded); + var decoded = Base64.decode(native_.getResultObject(result)); + + if (decoded.length) { + can_change_size = true; + this.position += decoded.length; + can_change_size = false; + } else { + this.position += 1; // Set EOF + } + + return decoded; }; FileStream.prototype.readBytes = function() { @@ -221,6 +238,15 @@ function readBase64() { throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Could not read'); } var encoded = native_.getResultObject(result); + var decoded = Base64.decode(encoded); + + if (decoded.length) { + can_change_size = true; + this.position += decoded.length; + can_change_size = false; + } else { + this.position += 1; // Set EOF + } return encoded; }; @@ -338,6 +364,12 @@ function writeBase64() { if (native_.isFailure(result)) { throw new WebAPIException(WebAPIException.IO_ERR, 'Could not write'); } + + var decoded = Base64.decode(args.base64Data); + + can_change_size = true; + this.position += decoded.length; + can_change_size = false; }; FileStream.prototype.writeBase64 = function() {