xdiff_file_patch

(no version information, might be only in CVS)

xdiff_file_patch -- Patche un fichier avec un diff unifié

Description

mixed xdiff_file_patch ( string file, string patch, string dest [, int flags] )

xdiff_file_patch() patche le fichier file avec le patch unifié dans le fichier patch et stocke le résultat dans le fichier dest.

flags peut être soit XDIFF_PATCH_NORMAL (mode par défaut, patch normal) ou XDIFF_PATCH_REVERSE (patch inversé).

Cette fonction retourne FALSE si une erreur interne s'est produite, une chaîne avec les parties rejetées du patch ou TRUE si le patch a été appliqué avec succès.

Exemple 1. Exemple avec xdiff_file_patch()

Le code suivant applique un diff à un fichier.

<?php
$ancienne_version
= 'mon_script-1.0.php';
$patch = 'mon_script.patch';

$errors = xdiff_file_patch($ancienne_version, $patch, 'my_script-1.1.php');
if (
is_string($errors)) {
   echo
"Rejets :\n";
   echo
$errors;
}

?>

Exemple 2. Exemple de retour à l'état initial après l'application d'un patch

Le code suivant annule un patch.

<?php
$nouvelle_version
= 'mon_script-1.1.php';
$patch = 'mon_script.patch';

$errors = xdiff_file_patch($nouvelle_version, $patch, 'mon_script-1.0.php', XDIFF_PATCH_REVERSE);
if (
is_string($errors)) {
   echo
"Rejets :\n";
   echo
$errors;
}

?>

Voir aussi xdiff_string_patch().