Changeset 815 for trunk/includes/FileStream.php
- Timestamp:
- Feb 22, 2015, 11:05:49 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/FileStream.php
r553 r815 7 7 private $Handle; 8 8 private $FileName; 9 9 10 10 function __construct() 11 11 { 12 12 $this->Handle = false; 13 } 14 15 function __destruct() 13 } 14 15 function __destruct() 16 16 { 17 17 if($this->Handle) 18 18 fclose($this->Handle); 19 19 } 20 20 21 21 public function OpenFile($FileName) 22 22 { … … 24 24 $this->CloseFile(); 25 25 $this->Handle = fopen($FileName, 'rb'); 26 if(!$this->Handle) die(str_replace('%s', $FileName, FILE_NOT_FOUND)); 26 if(!$this->Handle) die(str_replace('%s', $FileName, FILE_NOT_FOUND)); 27 27 } 28 28 … … 32 32 $this->CloseFile(); 33 33 $this->Handle = fopen($FileName, 'wb+'); 34 if(!$this->Handle) die(str_replace('%s', $FileName, FILE_NOT_FOUND)); 34 if(!$this->Handle) die(str_replace('%s', $FileName, FILE_NOT_FOUND)); 35 35 } 36 36 37 37 public function CloseFile() 38 38 { 39 39 if($this->Handle) 40 fclose($this->Handle); 40 fclose($this->Handle); 41 41 } 42 42 43 43 public function ReadBlock($Count) 44 44 { 45 45 return(fread($this->Handle, $Count)); 46 46 } 47 47 48 48 public function ReadByte() 49 49 { 50 50 return(fread($this->Handle, 1)); 51 } 52 51 } 52 53 53 public function ReadUint() 54 54 { … … 56 56 return($val[1]); 57 57 } 58 58 59 59 public function ReadInt() 60 60 { 61 61 $val = unpack('I*', fread($this->Handle, 4)); 62 62 return($val[1]); 63 } 64 63 } 64 65 65 public function ReadFloat() 66 66 { … … 68 68 return($val[1]); 69 69 } 70 70 71 71 public function ReadChar() 72 72 { … … 77 77 { 78 78 return(fgets($this->Handle)); 79 } 79 } 80 80 81 81 public function ReadTextLine() 82 82 { 83 83 return(fgets($this->Handle)); 84 } 85 84 } 85 86 86 public function WriteBlock($Value, $Count) 87 87 { 88 88 fwrite($this->Handle, $Value, $Count); 89 } 90 89 } 90 91 91 public function WriteByte($Value) 92 92 { 93 93 fwrite($this->Handle, pack('C*', $Value), 1); 94 } 95 94 } 95 96 96 public function WriteUint($Value) 97 97 { 98 98 fwrite($this->Handle, pack('V*', $Value), 4); 99 99 } 100 100 101 101 public function WriteInt($Value) 102 102 { 103 103 fwrite($this->Handle, pack('I*', $Value), 4); 104 } 105 104 } 105 106 106 public function WriteFloat($Value) 107 107 { 108 108 fwrite($this->Handle, pack('f*', $Value), 4); 109 109 } 110 110 111 111 public function WriteChar($Value) 112 112 { 113 113 fwrite($this->Handle, $Value, 1); 114 } 115 114 } 115 116 116 public function WriteString($Value) 117 117 { … … 128 128 fseek($this->Handle, $Position, SEEK_SET); 129 129 } 130 130 131 131 public function GetPosition() 132 132 { 133 133 return(ftell($this->Handle)); 134 134 } 135 135 136 136 public function GetSize() 137 137 {
Note:
See TracChangeset
for help on using the changeset viewer.