<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/PT-BR/fileRead?action=history&amp;feed=atom</id>
	<title>PT-BR/fileRead - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/PT-BR/fileRead?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=PT-BR/fileRead&amp;action=history"/>
	<updated>2026-04-09T19:01:59Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=PT-BR/fileRead&amp;diff=78716&amp;oldid=prev</id>
		<title>Lettify: Created page with &quot;__NOTOC__ {{BR/Funcao compartilhada}}  Faz a leitura de uma especificada quantidade de bytes de um determinado arquivo, começando em sua posição atual de leitura/gravação, e retorna o valor como uma ''string''.  ==Sintaxe== &lt;syntaxhighlight lang=&quot;lua&quot;&gt; string fileRead ( file theFile, int count ) &lt;/syntaxhighlight&gt;  {{PT-BR/POO||file:read}}  ===Argumentos necessários=== *'''theFile:''' O '''arquivo''' que deseja fazer a leitura. Use fileOpen p...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=PT-BR/fileRead&amp;diff=78716&amp;oldid=prev"/>
		<updated>2023-12-20T19:37:12Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;__NOTOC__ {{BR/Funcao compartilhada}}  Faz a leitura de uma especificada quantidade de bytes de um determinado arquivo, começando em sua posição atual de leitura/gravação, e retorna o valor como uma &amp;#039;&amp;#039;string&amp;#039;&amp;#039;.  ==Sintaxe== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; string fileRead ( file theFile, int count ) &amp;lt;/syntaxhighlight&amp;gt;  {{PT-BR/POO||&lt;a href=&quot;/index.php?title=File&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;File (page does not exist)&quot;&gt;file&lt;/a&gt;:read}}  ===Argumentos necessários=== *&amp;#039;&amp;#039;&amp;#039;theFile:&amp;#039;&amp;#039;&amp;#039; O &amp;#039;&amp;#039;&amp;#039;arquivo&amp;#039;&amp;#039;&amp;#039; que deseja fazer a leitura. Use &lt;a href=&quot;/wiki/PT-BR/fileOpen&quot; title=&quot;PT-BR/fileOpen&quot;&gt;fileOpen&lt;/a&gt; p...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__NOTOC__&lt;br /&gt;
{{BR/Funcao compartilhada}}&lt;br /&gt;
&lt;br /&gt;
Faz a leitura de uma especificada quantidade de bytes de um determinado arquivo, começando em sua posição atual de leitura/gravação, e retorna o valor como uma ''string''.&lt;br /&gt;
&lt;br /&gt;
==Sintaxe==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
string fileRead ( file theFile, int count )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{PT-BR/POO||[[file]]:read}}&lt;br /&gt;
&lt;br /&gt;
===Argumentos necessários===&lt;br /&gt;
*'''theFile:''' O '''arquivo''' que deseja fazer a leitura. Use [[PT-BR/fileOpen|fileOpen]] para obter esse '''arquivo''' mencionado.&lt;br /&gt;
*'''count:''' O número de bytes que deseja ler nesse ''arquivo''.&lt;br /&gt;
&lt;br /&gt;
===Retorno===&lt;br /&gt;
Returna os bytes que foram lidos, em uma ''string''. Observe que esta ''string'' poderá não conter toda a informação pela quantidade de bytes especificados para a leitura se tiver ocorrido algum erro, ex.: a posição de leitura estiver próximo ou literalmente no fim do arquivo.&lt;br /&gt;
&lt;br /&gt;
==Exemplo==&lt;br /&gt;
Este exemplo abre o arquivo &amp;quot;test.txt&amp;quot; e exibe seu conteúdo no console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function readFile(path)&lt;br /&gt;
    local file = fileOpen(path) -- tentamos abrir o arquivo&lt;br /&gt;
    if not file then&lt;br /&gt;
        return false -- paramos a função no caso de erro&lt;br /&gt;
    end&lt;br /&gt;
    local count = fileGetSize(file) -- obtemos o tamanho total do arquivo&lt;br /&gt;
    local data = fileRead(file, count) -- fazemos a leitura de todo o arquivo&lt;br /&gt;
    fileClose(file) -- fechamos o arquivo depois de feito todo o trabalho&lt;br /&gt;
    outputConsole(data) -- exibimos os dados no console&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;readfile&amp;quot;,function(cmd,fileName) -- adicionamos o comando para testar a função&lt;br /&gt;
    readFile(fileName) -- executa a função&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Detalhes relevantes ===&lt;br /&gt;
* [[PT-BR/fileOpen|fileOpen]] define a posição de leitura/gravação para o começo do arquivo.&lt;br /&gt;
* [[PT-BR/fileGetSize|fileGetSize]] obtém o tamanho total (em bytes) de um determinado arquivo.&lt;br /&gt;
&lt;br /&gt;
==Veja também==&lt;br /&gt;
{{PT-BR/File functions}}&lt;/div&gt;</summary>
		<author><name>Lettify</name></author>
	</entry>
</feed>