Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/Write-entire-file/Free-Pascal/write-entire-file.pas
Normal file
20
Task/Write-entire-file/Free-Pascal/write-entire-file.pas
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
program overwriteFile(input, output, stdErr);
|
||||
{$mode objFPC} // for exception treatment
|
||||
uses
|
||||
sysUtils; // for applicationName, getTempDir, getTempFileName
|
||||
// also: importing sysUtils converts all run-time errors to exceptions
|
||||
resourcestring
|
||||
hooray = 'Hello world!';
|
||||
var
|
||||
FD: text;
|
||||
begin
|
||||
// on a Debian GNU/Linux distribution,
|
||||
// this will write to /tmp/overwriteFile00000.tmp (or alike)
|
||||
assign(FD, getTempFileName(getTempDir(false), applicationName()));
|
||||
try
|
||||
rewrite(FD); // could fail, if user has no permission to write
|
||||
writeLn(FD, hooray);
|
||||
finally
|
||||
close(FD);
|
||||
end;
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue