| @@ 1065-1101 (lines=37) @@ | ||
| 1062 | } |
|
| 1063 | } |
|
| 1064 | ||
| 1065 | class CompressBzip2 extends CompressManagerFactory |
|
| 1066 | { |
|
| 1067 | private $fileHandler = null; |
|
| 1068 | ||
| 1069 | public function __construct() |
|
| 1070 | { |
|
| 1071 | if (! function_exists("bzopen")) { |
|
| 1072 | throw new Exception("Compression is enabled, but bzip2 lib is not installed or configured properly"); |
|
| 1073 | } |
|
| 1074 | } |
|
| 1075 | ||
| 1076 | /** |
|
| 1077 | * @param string $filename |
|
| 1078 | */ |
|
| 1079 | public function open($filename) |
|
| 1080 | { |
|
| 1081 | $this->fileHandler = bzopen($filename, "w"); |
|
| 1082 | if (false === $this->fileHandler) { |
|
| 1083 | throw new Exception("Output file is not writable"); |
|
| 1084 | } |
|
| 1085 | ||
| 1086 | return true; |
|
| 1087 | } |
|
| 1088 | ||
| 1089 | public function write($str) |
|
| 1090 | { |
|
| 1091 | if (false === ($bytesWritten = bzwrite($this->fileHandler, $str))) { |
|
| 1092 | throw new Exception("Writting to file failed! Probably, there is no more free space left?"); |
|
| 1093 | } |
|
| 1094 | return $bytesWritten; |
|
| 1095 | } |
|
| 1096 | ||
| 1097 | public function close() |
|
| 1098 | { |
|
| 1099 | return bzclose($this->fileHandler); |
|
| 1100 | } |
|
| 1101 | } |
|
| 1102 | ||
| 1103 | class CompressGzip extends CompressManagerFactory |
|
| 1104 | { |
|
| @@ 1103-1139 (lines=37) @@ | ||
| 1100 | } |
|
| 1101 | } |
|
| 1102 | ||
| 1103 | class CompressGzip extends CompressManagerFactory |
|
| 1104 | { |
|
| 1105 | private $fileHandler = null; |
|
| 1106 | ||
| 1107 | public function __construct() |
|
| 1108 | { |
|
| 1109 | if (! function_exists("gzopen")) { |
|
| 1110 | throw new Exception("Compression is enabled, but gzip lib is not installed or configured properly"); |
|
| 1111 | } |
|
| 1112 | } |
|
| 1113 | ||
| 1114 | /** |
|
| 1115 | * @param string $filename |
|
| 1116 | */ |
|
| 1117 | public function open($filename) |
|
| 1118 | { |
|
| 1119 | $this->fileHandler = gzopen($filename, "wb"); |
|
| 1120 | if (false === $this->fileHandler) { |
|
| 1121 | throw new Exception("Output file is not writable"); |
|
| 1122 | } |
|
| 1123 | ||
| 1124 | return true; |
|
| 1125 | } |
|
| 1126 | ||
| 1127 | public function write($str) |
|
| 1128 | { |
|
| 1129 | if (false === ($bytesWritten = gzwrite($this->fileHandler, $str))) { |
|
| 1130 | throw new Exception("Writting to file failed! Probably, there is no more free space left?"); |
|
| 1131 | } |
|
| 1132 | return $bytesWritten; |
|
| 1133 | } |
|
| 1134 | ||
| 1135 | public function close() |
|
| 1136 | { |
|
| 1137 | return gzclose($this->fileHandler); |
|
| 1138 | } |
|
| 1139 | } |
|
| 1140 | ||
| 1141 | class CompressNone extends CompressManagerFactory |
|
| 1142 | { |
|