@@ 1010-1046 (lines=37) @@ | ||
1007 | } |
|
1008 | } |
|
1009 | ||
1010 | class CompressBzip2 extends CompressManagerFactory |
|
1011 | { |
|
1012 | private $fileHandler = null; |
|
1013 | ||
1014 | public function __construct() |
|
1015 | { |
|
1016 | if (! function_exists("bzopen")) { |
|
1017 | throw new Exception("Compression is enabled, but bzip2 lib is not installed or configured properly"); |
|
1018 | } |
|
1019 | } |
|
1020 | ||
1021 | /** |
|
1022 | * @param string $filename |
|
1023 | */ |
|
1024 | public function open($filename) |
|
1025 | { |
|
1026 | $this->fileHandler = bzopen($filename, "w"); |
|
1027 | if (false === $this->fileHandler) { |
|
1028 | throw new Exception("Output file is not writable"); |
|
1029 | } |
|
1030 | ||
1031 | return true; |
|
1032 | } |
|
1033 | ||
1034 | public function write($str) |
|
1035 | { |
|
1036 | if (false === ($bytesWritten = bzwrite($this->fileHandler, $str))) { |
|
1037 | throw new Exception("Writting to file failed! Probably, there is no more free space left?"); |
|
1038 | } |
|
1039 | return $bytesWritten; |
|
1040 | } |
|
1041 | ||
1042 | public function close() |
|
1043 | { |
|
1044 | return bzclose($this->fileHandler); |
|
1045 | } |
|
1046 | } |
|
1047 | ||
1048 | class CompressGzip extends CompressManagerFactory |
|
1049 | { |
|
@@ 1048-1084 (lines=37) @@ | ||
1045 | } |
|
1046 | } |
|
1047 | ||
1048 | class CompressGzip extends CompressManagerFactory |
|
1049 | { |
|
1050 | private $fileHandler = null; |
|
1051 | ||
1052 | public function __construct() |
|
1053 | { |
|
1054 | if (! function_exists("gzopen")) { |
|
1055 | throw new Exception("Compression is enabled, but gzip lib is not installed or configured properly"); |
|
1056 | } |
|
1057 | } |
|
1058 | ||
1059 | /** |
|
1060 | * @param string $filename |
|
1061 | */ |
|
1062 | public function open($filename) |
|
1063 | { |
|
1064 | $this->fileHandler = gzopen($filename, "wb"); |
|
1065 | if (false === $this->fileHandler) { |
|
1066 | throw new Exception("Output file is not writable"); |
|
1067 | } |
|
1068 | ||
1069 | return true; |
|
1070 | } |
|
1071 | ||
1072 | public function write($str) |
|
1073 | { |
|
1074 | if (false === ($bytesWritten = gzwrite($this->fileHandler, $str))) { |
|
1075 | throw new Exception("Writting to file failed! Probably, there is no more free space left?"); |
|
1076 | } |
|
1077 | return $bytesWritten; |
|
1078 | } |
|
1079 | ||
1080 | public function close() |
|
1081 | { |
|
1082 | return gzclose($this->fileHandler); |
|
1083 | } |
|
1084 | } |
|
1085 | ||
1086 | class CompressNone extends CompressManagerFactory |
|
1087 | { |