1 <?xml version="1.0" encoding="UTF-8"?>
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) XXXX-2008 - INRIA
5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
6 * Copyright (C) 2018 - Samuel GOUGEON
8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
10 * This file was originally licensed under the terms of the CeCILL v2.1,
11 * and continues to be available under such terms.
12 * For more information, see the COPYING file which you should have received
13 * along with this program.
16 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
17 xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns4="http://www.w3.org/1999/xhtml"
18 xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
19 xmlns:scilab="http://www.scilab.org" xml:id="file" xml:lang="pt">
21 <refname>file</refname>
22 <refpurpose>Gerenciamento de arquivos</refpurpose>
25 <title>Seqüência de Chamamento</title>
27 [unit, err] = file("open", file-name [,status] [,access [,recl]] [,format])
30 file("backspace", unit)
32 [units, typ, nams, mod, swap] = file()
33 [units, typ, nams, mod, swap] = file(unit)
37 <title>Parâmetros</title>
40 <term>file-name</term>
42 <para>string, nome o arquivo a ser aberto</para>
44 This function can not open files whose path has non-ascii
45 UTF characters (accented, etc). In this case, please use mopen.
52 <para>string, o status do arquivo a ser aberto</para>
57 <para>o arquivo não deve existir, novo arquivo (padrão)</para>
63 <para>o arquivo já deve existir</para>
67 <term>"unknown"</term>
69 <para>status desconhecido</para>
73 <term>"scratch"</term>
75 <para>o arquivo deve ser deletado ao fim da sessão</para>
84 <para>string, o tipo de acesso ao arquivo</para>
87 <term>"sequential"</term>
89 <para>acesso seqüencial (padrão)</para>
95 <para>acesso direto</para>
107 <term>"formatted"</term>
109 <para>para um arquivo formatado (padrão)</para>
113 <term>"unformatted"</term>
115 <para>registro binário</para>
124 <para>inteiro, é o tamanho de registros quando
125 <literal>access="direct"</literal>
132 <para>inteiro, descritor de unidade lógica do arquivo aberto</para>
138 <para>vetor de inteiros, descritores de unidades lógicas dos
139 arquivos abertos. As unidades 5 e 6 são reservadas pelo sistema para
140 dispositivos de entrada e saída.
147 <para>vetor de strings, tipo (C ou Fortran) dos arquivos
155 <para>vetor de strings, endereços dos arquivos abertos.</para>
161 <para>modo de abertura de arquivo. Formado por três dígitos abc:
165 <td colspan="2"><emphasis role="bold">Arquivos Fortran</emphasis></td>
169 <td>0 significa formatado e 1 não formatado (binário)</td>
173 <td>0 significa acesso sequencial e 1 acesso direto</td>
177 <td>0 significa "new", 1 significa "old", 2 significa "scratch" e 3
182 <td colspan="2"><emphasis role="bold">Arquivos C</emphasis></td>
186 <td>1 significa "r" (leitura), 2 significa "w" (escrita) e 3 significa
191 <td>é 1 se o arquivo foi aberto pelo modo "+" (atualização)</td>
195 <td>é 1 se o arquivo foi aberto pelo modo "b" (binário)</td>
203 <para>alavanca de troca automática. swap=1 se a troca automática
204 estiver ativada. swap é sempre 0 para arquivos Fortran.
213 <para>inteiro, número de erro, se a abertura falha. Se <varname>err</varname>
214 for omitido, uma mensagem de erro aparece.
217 <tr valign="top"><th>65</th><td>File already used</td></tr>
218 <tr valign="top"><th>66</th><td>Too many files opened!</td></tr>
219 <tr valign="top"><th>67</th><td>Unknown file format</td></tr>
220 <tr valign="top"><th>240</th>
221 <td>The file already exists or directory write
222 access denied.</td></tr>
223 <tr valign="top"><th>241</th><td>The file does not exist or read access denied.</td></tr>
230 <para>é um dos seguintes strings:</para>
235 <para>fecha os arquivos fornecidos pelos descritores de
236 unidades lógicas fornecidos em <literal>units</literal>
241 <term>"rewind"</term>
243 <para>coloca o ponteiro no início do arquivo</para>
247 <term>"backspace"</term>
249 <para>coloca o ponteiro no início do último registro.</para>
255 <para>coloca o ponteiro após o último registro.</para>
264 <title>Descrição</title>
266 Seleciona uma unidade lógica <literal>unit</literal> e gerencia o
267 arquivo <literal>file-name</literal>.
270 <literal>[unit [,err]]=file('open', file-name [,status] [,access
273 permite abrir um arquivo com propriedades
274 especificadas e obter o número de unidade associado
275 <literal>unit</literal>. Este número de unidade pode ser utilizado para
276 ações futuras no arquivo, ou como descritor de arquivo em chamadas às
277 funções <literal>read</literal>, <literal>write</literal>,
278 <literal>readb</literal>,
279 <literal>writb</literal>,<literal>save</literal>,
280 <literal>load</literal>.
283 <literal>file(action,unit)</literal> permite fechar o arquivo, ou
284 mover o ponteiro do arquivo corrente.
287 <literal>file()</literal> retorna os descritores dos arquivos abertos.
289 <para>To test whether a file #<literal>id</literal> is opened,
290 <literal>file(id)~=[]</literal> may be used.
293 <literal>file('close',file() )</literal> fecha
294 todos os arquivos do usuário abertos (tipo C ou Fortran).
298 <title>Exemplos</title>
299 <programlisting role="example"><![CDATA[
300 u=file('open',TMPDIR+'/foo','unknown')
309 u1=file('open',TMPDIR+'/foo','unknown')
310 u2=mopen(TMPDIR+'/foo1','wb')
311 [units,typs,nams]=file()
316 <refsection role="see also">
317 <title>Ver Também</title>
318 <simplelist type="inline">
320 <link linkend="isfile">isfile</link>
323 <link linkend="read">read</link>
326 <link linkend="readb">readb</link>
329 <link linkend="write">write</link>
332 <link linkend="writb">writb</link>
335 <link linkend="mopen">mopen</link>
338 <link linkend="save">save</link>
341 <link linkend="load">load</link>
344 <link linkend="uigetfile">uigetfile</link>
348 <refsection role="history">
349 <title>Histórico</title>
352 <revnumber>6.0.0</revnumber>
354 stderr is inserted in the output of file() as units(1)=0, typ(1)="STD" and