php-doc-en/reference/xattr/functions/xattr-set.xml
Jakub Vrana a1ddba3e96 rtrim($refpurpose, '.')
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@166882 c90b9560-bf6c-de11-be94-00142212c4b1
2004-08-20 09:37:01 +00:00

107 lines
3.4 KiB
XML

<?xml version='1.0' encoding='iso-8859-1'?>
<!-- $Revision: 1.6 $ -->
<!-- Generated by xml_proto.php v2.0. Found in /scripts directory of phpdoc. -->
<refentry id="function.xattr-set">
<refnamediv>
<refname>xattr_set</refname>
<refpurpose>
Set an extended attribute
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>xattr_set</methodname>
<methodparam><type>string</type><parameter>path</parameter></methodparam>
<methodparam><type>string</type><parameter>name</parameter></methodparam>
<methodparam><type>string</type><parameter>value</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>flags</parameter></methodparam>
</methodsynopsis>
<para>
This function sets value of an extended attribute named <parameter>name</parameter>
to <parameter>value</parameter> of a file <parameter>path</parameter>.
Extended attribute will be created if it doesn't exist or replaced
otherwise. You can change this behaviour by using <parameter>flags</parameter>
parameter.
</para>
<para>
Extended attributes have two different namespaces: user and root namespace.
User namespace is available for all users while root namespace is available
only for user with root privileges. xattr operates on user namespace by default,
but you can change that using <parameter>flags</parameter> argument.
</para>
<para>
<table>
<title>Supported xattr flags</title>
<tgroup cols="2">
<tbody>
<row>
<entry>XATTR_CREATE</entry>
<entry>Function will fail if extended attribute already exists.</entry>
</row>
<row>
<entry>XATTR_REPLACE</entry>
<entry>Function will fail if extended attribute doesn't exist.</entry>
</row>
<row>
<entry>XATTR_DONTFOLLOW</entry>
<entry>Do not follow the symbolic link but operate on symbolic link itself.</entry>
</row>
<row>
<entry>XATTR_ROOT</entry>
<entry>Set attribute in root (trusted) namespace. Requires root privileges.</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
&return.success;
</para>
<example>
<title><function>xattr_set</function> example</title>
<para>
The following code sets extended attributes on .wav file.
</para>
<programlisting role="php">
<![CDATA[
<?php
$file = 'my_favourite_song.wav';
xattr_set($file, 'Artist', 'Someone');
xattr_set($file, 'My ranking', 'Good');
xattr_set($file, 'Listen count', '34');
/* ... other code ... */
printf("You've played this song %d times", xattr_get($file, 'Listen count'));
?>
]]>
</programlisting>
</example>
<para>
See also <function>xattr_get</function>, <function>xattr_remove</function>,
<function>xattr_list</function>, <function>xattr_supported</function>.
</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:"../../../../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
-->