Skip to content

Commit

Permalink
Replace gsplit with split on mac.
Browse files Browse the repository at this point in the history
  • Loading branch information
vielhuber committed Jan 10, 2024
1 parent 9c50198 commit 51d53bc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/magicreplace.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ public static function run($input, $output, $search_replace, $progress = false)
return;
}
// split source file in several files
if( self::getOs() === 'mac' ) { $command = 'gsplit'; }
elseif ( self::getOs() === 'windows' || self::getOs() === 'linux' ) { $command = 'split'; }
// so that we don't get a memory limit error in php
// on mac we don't use "gsplit" here, since it has a weird bug
// where corrupted characters get introduced after splitting
// instead we use split but use another argument (-C is not available)
$command = 'split';
if( self::getOs() === 'mac' ) { $command .= ' -l 3000'; }
elseif ( self::getOs() === 'windows' || self::getOs() === 'linux' ) { $command .= ' -C 1m'; }
else { die('unknown operating system'); }
exec($command . ' -C 1m "'.$input.'" "'.$input.'-SPLITTED"');
exec($command . ' "'.$input.'" "'.$input.'-SPLITTED"');
$filenames = glob($input.'-SPLITTED*');
foreach( $filenames as $filenames__key=>$filenames__value )
{
Expand Down

0 comments on commit 51d53bc

Please sign in to comment.