-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added load and save method for HproseBytesIO.
- Loading branch information
Showing
1 changed file
with
13 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
* * | ||
* hprose BytesIO class for php 5.3+ * | ||
* * | ||
* LastModified: Mar 6, 2015 * | ||
* LastModified: Apr 6, 2015 * | ||
* Author: Ma Bingyao <[email protected]> * | ||
* * | ||
\**********************************************************/ | ||
|
@@ -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; | ||
} | ||
|