<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">Am 06.10.20 um 01:08 schrieb Jean
SUZINEAU via fpc-pascal:<br>
</div>
<blockquote type="cite"
cite="mid:b2eeeff1-fec0-6753-4339-b39047dfa96b@wanadoo.fr">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<p>In my own code I use BlockRead/BlockWrite, but I'm wondering if
I've not seen this somewhere in RTL.<br>
</p>
<p><a moz-do-not-send="true"
href="https://github.com/jsuzineau/pascal_o_r_mapping/blob/TjsDataContexte/pascal_o_r_mapping/02_Units/uuStrings.pas">https://github.com/jsuzineau/pascal_o_r_mapping/blob/TjsDataContexte/pascal_o_r_mapping/02_Units/uuStrings.pas</a></p>
<pre>function String_from_File( _FileName: String): String;</pre>
<pre>var</pre>
<pre> F: File;</pre>
<pre> Longueur: Integer;</pre>
<pre>begin</pre>
<pre> Result:= '';</pre>
<pre> if not FileExists( _FileName) then exit;</pre>
<pre> AssignFile( F, _FileName);</pre>
<pre> try</pre>
<pre> Reset( F, 1);</pre>
<pre> Longueur:= FileSize( F);</pre>
<pre> if 0 = Longueur then exit;</pre>
<pre> SetLength( Result, Longueur);</pre>
<pre> BlockRead( F, Result[1], Longueur);</pre>
<pre> finally</pre>
<pre> CloseFile( F);</pre>
<pre> end;</pre>
<pre>end;</pre>
<pre>procedure String_to_File( _FileName: String; _S: String);</pre>
<pre>var</pre>
<pre> F: File;</pre>
<pre>begin</pre>
<pre> if '' = _S then exit;</pre>
<pre> AssignFile( F, _FileName);</pre>
<pre> try</pre>
<pre> ReWrite( F, 1);</pre>
<pre> BlockWrite( F, _S[1], Length( _S));</pre>
<pre> finally</pre>
<pre> CloseFile( F);</pre>
<pre> end;</pre>
<pre>end;</pre>
<p><br>
</p>
</blockquote>
<p>Hi!</p>
<p><br>
</p>
<p>Great idea!</p>
<p>Longueur should be Int64</p>
<p><br>
</p>
<p>Winni<br>
</p>
<pre>
</pre>
<p><br>
</p>
<p><br>
</p>
<blockquote type="cite"
cite="mid:b2eeeff1-fec0-6753-4339-b39047dfa96b@wanadoo.fr">
<p> </p>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
fpc-pascal maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a>
</pre>
</blockquote>
</body>
</html>