[Filesystem] - update position and eof attributes of fileStream in read 16/90816/3
authorAndrzej Popowski <a.popowski@samsung.com>
Tue, 4 Oct 2016 09:43:00 +0000 (11:43 +0200)
committerAndrzej Popowski <a.popowski@samsung.com>
Tue, 4 Oct 2016 10:51:47 +0000 (03:51 -0700)
[Verification] - TCT results 100%

Change-Id: If03b99e8b3ef0619f981353a096c1c5c414cabc8
Signed-off-by: Andrzej Popowski <a.popowski@samsung.com>
src/filesystem/js/file_stream.js

index 2036254b586b0b17da7e36759d1830bdb369dc78..2abc68ff83b557e5a466cad3f069af595ffbce4a 100644 (file)
@@ -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() {