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