Repository navigation
Expand file tree
/
Copy pathstat.xml
More file actions
359 lines (345 loc) · 10 KB
/
Copy pathstat.xml
File metadata and controls
359 lines (345 loc) · 10 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: f80105b4fc1196bd8d5fecb98d686b580b1ff65d Maintainer: PhilDaiguille Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="function.stat" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>stat</refname>
<refpurpose>Proporciona información sobre un fichero</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type class="union"><type>array</type><type>false</type></type><methodname>stat</methodname>
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
</methodsynopsis>
<para>
Proporciona información sobre el fichero <parameter>filename</parameter>.
Si <parameter>filename</parameter> es un enlace simbólico, la información
proviene del fichero en sí, y no del enlace simbólico.
Antes de PHP 7.4.0, en Windows <abbrev>NTS</abbrev> compila los valores estáticos
<literal>size</literal>, <literal>atime</literal>, <literal>mtime</literal> y
<literal>ctime</literal> desde los enlaces simbólicos, en este caso.
</para>
<para>
<function>lstat</function> es idéntico a
<function>stat</function> excepto que la información se basa
en el enlace simbólico.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>filename</parameter></term>
<listitem>
<para>
La ruta al fichero.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
<table>
<title>Formato del resultado de <function>stat</function> y
<function>fstat</function></title>
<tgroup cols="3">
<thead>
<row>
<entry>Número</entry>
<entry>Nombre</entry>
<entry>Descripción</entry>
</row>
</thead>
<tbody>
<row>
<entry>0</entry>
<entry>dev</entry>
<entry>volumen (***)</entry>
</row>
<row>
<entry>1</entry>
<entry>ino</entry>
<entry>Número de inodo (****)</entry>
</row>
<row>
<entry>2</entry>
<entry>mode</entry>
<entry>derechos de acceso al inodo *****</entry>
</row>
<row>
<entry>3</entry>
<entry>nlink</entry>
<entry>número de enlaces</entry>
</row>
<row>
<entry>4</entry>
<entry>uid</entry>
<entry>userid del propietario (*)</entry>
</row>
<row>
<entry>5</entry>
<entry>gid</entry>
<entry>groupid del propietario (*)</entry>
</row>
<row>
<entry>6</entry>
<entry>rdev</entry>
<entry>tipo de volumen, si el volumen es un inodo</entry>
</row>
<row>
<entry>7</entry>
<entry>size</entry>
<entry>tamaño en bytes</entry>
</row>
<row>
<entry>8</entry>
<entry>atime</entry>
<entry>fecha del último acceso (timestamp Unix)</entry>
</row>
<row>
<entry>9</entry>
<entry>mtime</entry>
<entry>fecha de la última modificación (timestamp Unix)</entry>
</row>
<row>
<entry>10</entry>
<entry>ctime</entry>
<entry>fecha del último cambio de inodo (timestamp Unix)</entry>
</row>
<row>
<entry>11</entry>
<entry>blksize</entry>
<entry>tamaño de bloque (**)</entry>
</row>
<row>
<entry>12</entry>
<entry>blocks</entry>
<entry>número de bloques de 512 bytes asignados (**)</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
* - En Windows, esto siempre será <literal>0</literal>.
</para>
<para>
** - Solo en sistemas que soportan el tipo <literal>st_blksize</literal>.
Los otros sistemas (ej. Windows) devuelven <literal>-1</literal>.
</para>
<para>
*** - En Windows, desde PHP 7.4.0, será el número de serie del volumen que
contiene el fichero, que será un entero 64-bit <emphasis>sin signo</emphasis>
que puede desbordarse. Anteriormente, era la representación numérica de la letra
del volumen (ej. <literal>2</literal> para <literal>C:</literal>) para la función
<function>stat</function>, y <literal>0</literal> para la función
<function>lstat</function>.
</para>
<para>
**** - En Windows, desde PHP 7.4.0, es el identificador asociado con el fichero,
que será un entero 64-bit <emphasis>sin signo</emphasis> que puede desbordarse.
Anteriormente, siempre era <literal>0</literal>.
</para>
<para>
***** En Windows, el bit de permiso de escritura se define en función del atributo
de solo lectura del fichero, y el mismo valor se reporta para todos los usuarios,
grupo y propietario. El ACL no se tiene en cuenta, a diferencia de
<function>is_writable</function>.
</para>
<para>
El valor de <literal>mode</literal> contiene información leída por
varias funciones. Cuando se escribe en octal, comenzando por la derecha,
los tres primeros dígitos son devueltos por <function>chmod</function>.
El siguiente dígito es ignorado por PHP. Los dos siguientes dígitos indican
el tipo de fichero:
<table>
<title>Los tipos de ficheros <literal>mode</literal></title>
<tgroup cols="2">
<thead>
<row>
<entry><literal>mode</literal> en octal</entry>
<entry>Significado</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>0140000</literal></entry>
<entry>socket</entry>
</row>
<row>
<entry><literal>0120000</literal></entry>
<entry>enlace simbólico</entry>
</row>
<row>
<entry><literal>0100000</literal></entry>
<entry>fichero regular</entry>
</row>
<row>
<entry><literal>0060000</literal></entry>
<entry>dispositivo de bloque</entry>
</row>
<row>
<entry><literal>0040000</literal></entry>
<entry>directorio</entry>
</row>
<row>
<entry><literal>0020000</literal></entry>
<entry>dispositivo de carácter</entry>
</row>
<row>
<entry><literal>0010000</literal></entry>
<entry>FIFO (un tubo nombrado)</entry>
</row>
</tbody>
</tgroup>
</table>
Por ejemplo, un fichero regular podría ser
<literal>0100644</literal> y un directorio podría
<literal>0040755</literal>.
</para>
<para>
En caso de error, <function>stat</function> devuelve &false;.
</para>
&fs.file.32bit;
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Si ocurre un error, se emite una advertencia de tipo
<constant>E_WARNING</constant>.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>7.4.0</entry>
<entry>
En Windows, el número del volumen es ahora el número de serie que contiene
el fichero, y el número de inodo es el identificador asociado con el fichero.
</entry>
</row>
<row>
<entry>7.4.0</entry>
<entry>
Los valores estáticos <literal>size</literal>, <literal>atime</literal>,
<literal>mtime</literal> y <literal>ctime</literal> de los enlaces simbólicos
son siempre los de la meta. Esto no era así previamente
para los builds <abbrev>NTS</abbrev> en Windows.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Ejemplo con <function>stat</function></title>
<programlisting role="php">
<![CDATA[
<?php
/* Obtención de la información */
$stat = stat('C:\php\php.exe');
/*
* Mostrar la fecha y hora del acceso a este fichero,
* idéntico a la llamada a la función fileatime()
*/
echo 'Fecha y hora de acceso : ' . $stat['atime'];
/*
* Mostrar la fecha y hora de modificación del fichero,
* idéntico a la llamada a la función filemtime()
*/
echo 'Fecha y hora de modificación : ' . $stat['mtime'];
/* Mostrar el número del dispositivo */
echo 'Número del dispositivo : ' . $stat['dev'];
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>Uso de la información obtenida de <function>stat</function>
junto con la función <function>touch</function></title>
<programlisting role="php">
<![CDATA[
<?php
/* Obtención de la información de la función stat */
$stat = stat('C:\php\php.exe');
/* ¿Ha fallado el acceso a la información? */
if (!$stat) {
echo 'La llamada a stat() ha fallado...';
} else {
/*
* Queremos que la fecha y hora de acceso sea una
* semana después de la fecha actual.
*/
$atime = $stat['atime'] + 604800;
/* Modificamos el fichero */
if(!touch('some_file.txt', time(), $atime)) {
echo 'Fallo al llamar a la función touch()...';
} else {
echo 'La llamada a touch() ha tenido éxito...';
}
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
¬e.filesystem-time-res;
¬e.clearstatcache;
&tip.fopen-wrapper.stat;
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>lstat</function></member>
<member><function>fstat</function></member>
<member><function>filemtime</function></member>
<member><function>filegroup</function></member>
<member><classname>SplFileInfo</classname></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
-->