function coder_upgrade_make_patch_file in Coder 7.2
Same name and namespace in other branches
- 7 coder_upgrade/includes/main.inc \coder_upgrade_make_patch_file()
Makes a patch file of the conversion routine changes.
Parameters
array $item: Array of the directory containing the files to convert.
boolean $_coder_upgrade_replace_files: Indicates whether to replace the original files.
1 call to coder_upgrade_make_patch_file()
- coder_upgrade_start in coder_upgrade/
includes/ main.inc - Prepares conversion environment and starts conversion loop.
File
- coder_upgrade/
includes/ main.inc, line 565 - Manages application of conversion routines, logging, and patch file creation.
Code
function coder_upgrade_make_patch_file($item, $_coder_upgrade_replace_files = FALSE) {
// Patch directory.
$patch_dir = coder_upgrade_directory_path('patch');
// Make a patch file.
coder_upgrade_log_print("\n*************************");
coder_upgrade_log_print('Creating a patch file for the directory => ' . $item['old_dir']);
coder_upgrade_log_print("*************************");
$patch_filename = $patch_dir . $item['name'] . '.patch';
// Swap directories if files are replaced.
$old_dir = $_coder_upgrade_replace_files ? $item['new_dir'] : $item['old_dir'];
$new_dir = $_coder_upgrade_replace_files ? $item['old_dir'] : $item['new_dir'];
coder_upgrade_log_print("Making patch file: diff -up -r {$old_dir} {$new_dir} > {$patch_filename}");
shell_exec("diff -up -r {$old_dir} {$new_dir} > {$patch_filename}");
// Remove the path strings from the patch file (for usability purposes).
$old1 = $old_dir . '/';
$new1 = $new_dir . '/';
$contents = file_get_contents($patch_filename);
file_put_contents($patch_filename, str_replace(array(
$old1,
$new1,
), '', $contents));
}