File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ class BinaryStream {
18
18
* @var resource The file pointer
19
19
*/
20
20
protected $ f ;
21
+ protected $ f2 ;
21
22
22
23
const uint8 = 1 ;
23
24
const int8 = 2 ;
@@ -66,6 +67,9 @@ public function open($filename, $mode = self::modeRead) {
66
67
throw new \Exception ("Unknown file open mode " );
67
68
}
68
69
70
+ if ($ this ->f != null && $ this ->f != false ) {
71
+ $ this ->f2 = $ this ->f ;
72
+ }
69
73
$ this ->f = fopen ($ filename , $ mode );
70
74
71
75
return $ this ->f != false ;
@@ -75,9 +79,20 @@ public function open($filename, $mode = self::modeRead) {
75
79
* Close the internal file pointer
76
80
*/
77
81
public function close () {
82
+ if ($ this ->f2 !== null && $ this ->f2 !== false ) {
83
+ fclose ($ this ->f2 );
84
+ }
78
85
return fclose ($ this ->f ) != false ;
79
86
}
80
87
88
+ public function revert () {
89
+ if ($ this ->f2 !== null ) {
90
+ fclose ($ this ->f );
91
+ $ this ->f = $ this ->f2 ;
92
+ $ this ->f2 = null ;
93
+ }
94
+ }
95
+
81
96
/**
82
97
* Change the internal file pointer
83
98
*
You can’t perform that action at this time.
0 commit comments