Skip to content

Commit 376fb99

Browse files
committed
Added method to retrieve written dump filename (including compressed file extension)
1 parent bf24295 commit 376fb99

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

src/Ifsnop/Mysqldump/Mysqldump.php

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,16 @@ public function start($filename = '')
269269
$this->compressManager->close();
270270
}
271271

272+
/**
273+
* Returns written archive filename
274+
*
275+
* @return string
276+
*/
277+
public function getFilename()
278+
{
279+
return $this->compressManager->getArchiveFilename();
280+
}
281+
272282
/**
273283
* Returns header for dump file
274284
*
@@ -719,6 +729,8 @@ public static function isValid($c)
719729

720730
abstract class CompressManagerFactory
721731
{
732+
protected $archiveFilename;
733+
722734
/**
723735
* @param string $c
724736
* @return CompressBzip2|CompressGzip|CompressNone
@@ -734,6 +746,11 @@ public static function create($c)
734746

735747
return new $method;
736748
}
749+
750+
public function getArchiveFilename()
751+
{
752+
return $this->archiveFilename;
753+
}
737754
}
738755

739756
class CompressBzip2 extends CompressManagerFactory
@@ -749,7 +766,8 @@ public function __construct()
749766

750767
public function open($filename)
751768
{
752-
$this->fileHandler = bzopen($filename . ".bz2", "w");
769+
$this->archiveFilename = $filename . ".bz2";
770+
$this->fileHandler = bzopen($this->archiveFilename, "w");
753771
if (false === $this->fileHandler) {
754772
throw new Exception("Output file is not writable");
755773
}
@@ -784,7 +802,8 @@ public function __construct()
784802

785803
public function open($filename)
786804
{
787-
$this->fileHandler = gzopen($filename . ".gz", "wb");
805+
$this->archiveFilename = $filename . ".gz";
806+
$this->fileHandler = gzopen($this->archiveFilename, "wb");
788807
if (false === $this->fileHandler) {
789808
throw new Exception("Output file is not writable");
790809
}
@@ -812,7 +831,8 @@ class CompressNone extends CompressManagerFactory
812831

813832
public function open($filename)
814833
{
815-
$this->fileHandler = fopen($filename, "wb");
834+
$this->archiveFilename = $filename;
835+
$this->fileHandler = fopen($this->archiveFilename, "wb");
816836
if (false === $this->fileHandler) {
817837
throw new Exception("Output file is not writable");
818838
}
@@ -1041,7 +1061,7 @@ public function parseColumnType($colType)
10411061
{
10421062
return array();
10431063
}
1044-
1064+
10451065
public function backup_parameters()
10461066
{
10471067
return PHP_EOL;

0 commit comments

Comments
 (0)