mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-25 17:32:07 +01:00
131 lines
3.6 KiB
XML
131 lines
3.6 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 60809ebcf7d0c261b2f00e093e4fab70326ffc7b Maintainer: yannick Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
<refentry xml:id="splfileobject.flock" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>SplFileObject::flock</refname>
|
|
<refpurpose>Verrouille ou déverrouille un fichier</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<modifier>public</modifier> <type>bool</type><methodname>SplFileObject::flock</methodname>
|
|
<methodparam><type>int</type><parameter>operation</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter role="reference">wouldBlock</parameter><initializer>&null;</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Verrouille ou déverrouille un fichier, de la même façon que la fonction
|
|
<function>flock</function>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>operation</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Le paramètre <parameter>operation</parameter> peut prendre une des constantes suivantes :
|
|
<itemizedlist>
|
|
<listitem>
|
|
<simpara>
|
|
<constant>LOCK_SH</constant> pour acquérir un verrou partagé (lecture).
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<constant>LOCK_EX</constant> pour acquérir un verrou exclusif (écriture).
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<constant>LOCK_UN</constant> pour déverrouiller le fichier (partagé ou exclusif).
|
|
</simpara>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
<para>
|
|
Il est aussi possible d'ajouter <constant>LOCK_NB</constant> en tant qu'un
|
|
masque binaire à l'une des opérations ci-dessus, si
|
|
<function>flock</function> ne devrait pas bloquer lors de la tentative
|
|
de vérrouillage.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>wouldBlock</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Définit à &true; si le verrou doit être bloquant (condition pour l'errno EWOULDBLOCK).
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.success;
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Exemple avec <methodname>SplFileObject::flock</methodname></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$file = new SplFileObject("/tmp/lock.txt", "w");
|
|
if ($file->flock(LOCK_EX)) { // verrou exclusif
|
|
$file->ftruncate(0); // coupe le fichier
|
|
$file->fwrite("Écrire quelque chose ici\n");
|
|
$file->flock(LOCK_UN); // libère le verrou
|
|
} else {
|
|
echo "Impossible de récupérer le verrou !";
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>flock</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|