MediaWiki REL1_32
Dump7ZipOutput.php
Go to the documentation of this file.
1<?php
34
39 function __construct( $file, $cmpLevel = 4 ) {
40 $this->compressionLevel = $cmpLevel;
41 $command = $this->setup7zCommand( $file );
42 parent::__construct( $command );
43 $this->filename = $file;
44 }
45
50 function setup7zCommand( $file ) {
51 $command = "7za a -bd -si -mx=";
52 $command .= wfEscapeShellArg( $this->compressionLevel ) . ' ';
53 $command .= wfEscapeShellArg( $file );
54 // Suppress annoying useless crap from p7zip
55 // Unfortunately this could suppress real error messages too
56 $command .= ' >' . wfGetNull() . ' 2>&1';
57 return $command;
58 }
59
64 function closeAndRename( $newname, $open = false ) {
65 $newname = $this->checkRenameArgCount( $newname );
66 if ( $newname ) {
67 fclose( $this->handle );
68 proc_close( $this->procOpenResource );
69 $this->renameOrException( $newname );
70 if ( $open ) {
71 $command = $this->setup7zCommand( $this->filename );
72 $this->startCommand( $command );
73 }
74 }
75 }
76}
wfEscapeShellArg(... $args)
Version of escapeshellarg() that works better on Windows.
wfGetNull()
Get a platform-independent path to the null file, e.g.
__construct( $file, $cmpLevel=4)
closeAndRename( $newname, $open=false)
checkRenameArgCount( $newname)
renameOrException( $newname)
startCommand( $command)