<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.xdiff.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.xdiff-file-patch.php',
    1 => 'xdiff_file_patch',
    2 => 'Patche un fichier avec un diff unifi&eacute;',
  ),
  'up' => 
  array (
    0 => 'ref.xdiff.php',
    1 => 'Fonctions xdiff',
  ),
  'prev' => 
  array (
    0 => 'function.xdiff-file-merge3.php',
    1 => 'xdiff_file_merge3',
  ),
  'next' => 
  array (
    0 => 'function.xdiff-file-patch-binary.php',
    1 => 'xdiff_file_patch_binary',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/xdiff/functions/xdiff-file-patch.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.xdiff-file-patch" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">xdiff_file_patch</h1>
  <p class="verinfo">(PECL xdiff &gt;= 0.2.0)</p><p class="refpurpose"><span class="refname">xdiff_file_patch</span> &mdash; <span class="dc-title">Patche un fichier avec un diff unifié</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.xdiff-file-patch-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>xdiff_file_patch</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$file</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$patch</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$dest</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$flags</code><span class="initializer"> = DIFF_PATCH_NORMAL</span></span><br>): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>

  <p class="para rdfs-comment">
   Patche le fichier <code class="parameter">file</code> avec le patch fourni par
   le paramètre <code class="parameter">patch</code> et enregistre le résultat dans un
   fichier. <code class="parameter">patch</code> doit être un diff unifié créé par la
   fonction <span class="function"><a href="function.xdiff-file-diff.php" class="function">xdiff_file_diff()</a></span>/<span class="function"><a href="function.xdiff-string-diff.php" class="function">xdiff_string_diff()</a></span>.
   Un paramètre optionnel <code class="parameter">flags</code> spécifie le mode de
   l&#039;opération.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.xdiff-file-patch-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">file</code></dt>
     <dd>
      <p class="para">
       Le fichier original.
      </p>
     </dd>
    
    
     <dt><code class="parameter">patch</code></dt>
     <dd>
      <p class="para">
       Le fichier contenant le patch unifié. Il doit avoir été créé en utilisant
       les fonctions <span class="function"><a href="function.xdiff-string-diff.php" class="function">xdiff_string_diff()</a></span>,
       <span class="function"><a href="function.xdiff-file-diff.php" class="function">xdiff_file_diff()</a></span> ou par des outils compatibles.
      </p>
     </dd>
    
    
     <dt><code class="parameter">dest</code></dt>
     <dd>
      <p class="para">
       Le chemin vers le fichier résultat.
      </p>
     </dd>
    
    
     <dt><code class="parameter">flags</code></dt>
     <dd>
      <p class="para">
       Peut être soit <strong><code><a href="xdiff.constants.php#constant.xdiff-patch-normal">XDIFF_PATCH_NORMAL</a></code></strong> (mode par
       défaut, patch normal) ou <strong><code><a href="xdiff.constants.php#constant.xdiff-patch-reverse">XDIFF_PATCH_REVERSE</a></code></strong>
       (patch inversé).
      </p>
      <p class="para">
       Depuis la version 1.5.0, il est également possible d&#039;utiliser l&#039;opérateur
       binaire OR pour activer le drapeau
       <strong><code>XDIFF_PATCH_IGNORESPACE</code></strong>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.xdiff-file-patch-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Retourne <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> si une erreur interne s&#039;est produite, une
   chaîne avec les parties rejetées du <code class="parameter">patch</code> si c&#039;est le
   cas ou <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> si le <code class="parameter">patch</code> a été appliqué avec succès.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.xdiff-file-patch-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Exemple avec <span class="function"><strong>xdiff_file_patch()</strong></span></strong></p>
    <div class="example-contents"><p>
     Le code suivant applique un diff à un fichier.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$old_version </span><span style="color: #007700">= </span><span style="color: #DD0000">'my_script-1.0.php'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$patch </span><span style="color: #007700">= </span><span style="color: #DD0000">'my_script.patch'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$errors </span><span style="color: #007700">= </span><span style="color: #0000BB">xdiff_file_patch</span><span style="color: #007700">(</span><span style="color: #0000BB">$old_version</span><span style="color: #007700">, </span><span style="color: #0000BB">$patch</span><span style="color: #007700">, </span><span style="color: #DD0000">'my_script-1.1.php'</span><span style="color: #007700">);<br />if (</span><span style="color: #0000BB">is_string</span><span style="color: #007700">(</span><span style="color: #0000BB">$errors</span><span style="color: #007700">)) {<br />   echo </span><span style="color: #DD0000">"Rejets :\n"</span><span style="color: #007700">;<br />   echo </span><span style="color: #0000BB">$errors</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
   <div class="example" id="example-2">
    <p><strong>Exemple #2 Exemple de retour à l&#039;état initial après l&#039;application d&#039;un patch</strong></p>
    <div class="example-contents"><p>
     Le code suivant annule un patch.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$new_version </span><span style="color: #007700">= </span><span style="color: #DD0000">'my_script-1.1.php'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$patch </span><span style="color: #007700">= </span><span style="color: #DD0000">'my_script.patch'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$errors </span><span style="color: #007700">= </span><span style="color: #0000BB">xdiff_file_patch</span><span style="color: #007700">(</span><span style="color: #0000BB">$new_version</span><span style="color: #007700">, </span><span style="color: #0000BB">$patch</span><span style="color: #007700">, </span><span style="color: #DD0000">'my_script-1.0.php'</span><span style="color: #007700">, </span><span style="color: #0000BB">XDIFF_PATCH_REVERSE</span><span style="color: #007700">);<br />if (</span><span style="color: #0000BB">is_string</span><span style="color: #007700">(</span><span style="color: #0000BB">$errors</span><span style="color: #007700">)) {<br />   echo </span><span style="color: #DD0000">"Rejets :\n"</span><span style="color: #007700">;<br />   echo </span><span style="color: #0000BB">$errors</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.xdiff-file-patch-seealso">
  <h3 class="title">Voir aussi</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.xdiff-file-diff.php" class="function" rel="rdfs-seeAlso">xdiff_file_diff()</a> - Cr&eacute;e un diff unifi&eacute; entre deux fichiers</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>