File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-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,12 @@ 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
+ if ($ this ->f2 !== null && $ this ->f2 !== false ) {
72
+ fclose ($ this ->f2 );
73
+ }
74
+ $ this ->f2 = $ this ->f ;
75
+ }
69
76
$ this ->f = fopen ($ filename , $ mode );
70
77
71
78
return $ this ->f != false ;
@@ -75,9 +82,20 @@ public function open($filename, $mode = self::modeRead) {
75
82
* Close the internal file pointer
76
83
*/
77
84
public function close () {
85
+ if ($ this ->f2 !== null && $ this ->f2 !== false ) {
86
+ fclose ($ this ->f2 );
87
+ }
78
88
return fclose ($ this ->f ) != false ;
79
89
}
80
90
91
+ public function revert () {
92
+ if ($ this ->f2 !== null ) {
93
+ fclose ($ this ->f );
94
+ $ this ->f = $ this ->f2 ;
95
+ $ this ->f2 = null ;
96
+ }
97
+ }
98
+
81
99
/**
82
100
* Change the internal file pointer
83
101
*
You can’t perform that action at this time.
0 commit comments