MediaWiki  master
Dump7ZipOutput.php
Go to the documentation of this file.
1 <?php
27 
35  protected $compressionLevel;
36 
41  public function __construct( $file, $cmpLevel = 4 ) {
42  $this->compressionLevel = $cmpLevel;
43  $command = $this->setup7zCommand( $file );
44  parent::__construct( $command );
45  $this->filename = $file;
46  }
47 
52  function setup7zCommand( $file ) {
53  $command = "7za a -bd -si -mx=";
54  $command .= Shell::escape( $this->compressionLevel ) . ' ';
55  $command .= Shell::escape( $file );
56  // Suppress annoying useless crap from p7zip
57  // Unfortunately this could suppress real error messages too
58  $command .= ' >' . wfGetNull() . ' 2>&1';
59  return $command;
60  }
61 
65  function closeAndRename( $newname, $open = false ) {
66  $newname = $this->checkRenameArgCount( $newname );
67  if ( $newname ) {
68  fclose( $this->handle );
69  proc_close( $this->procOpenResource );
70  $this->renameOrException( $newname );
71  if ( $open ) {
72  $command = $this->setup7zCommand( $this->filename );
73  $this->startCommand( $command );
74  }
75  }
76  }
77 }
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition: router.php:42
startCommand( $command)
renameOrException( $newname)
closeAndRename( $newname, $open=false)
setup7zCommand( $file)
__construct( $file, $cmpLevel=4)
wfGetNull()
Get a platform-independent path to the null file, e.g.
checkRenameArgCount( $newname)