Skip to content

Commit

Permalink
Added load and save method for HproseBytesIO.
Browse files Browse the repository at this point in the history
  • Loading branch information
andot committed Apr 7, 2015
1 parent 33eae5b commit 6cb2027
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Hprose/BytesIO.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* *
* hprose BytesIO class for php 5.3+ *
* *
* LastModified: Mar 6, 2015 *
* LastModified: Apr 6, 2015 *
* Author: Ma Bingyao <[email protected]> *
* *
\**********************************************************/
Expand Down Expand Up @@ -137,6 +137,18 @@ public function write($str, $n = -1) {
}
$this->length += $n;
}
public function load($filename) {
$str = file_get_contents($filename);
if ($str === false) return false;
$this->buffer = $str;
$this->pos = 0;
$this->mark = -1;
$this->length = strlen($str);
return true;
}
public function save($filename) {
return file_put_contents($filename, $this->buffer);
}
public function toString() {
return $this->buffer;
}
Expand Down

0 comments on commit 6cb2027

Please sign in to comment.