Make a backup file: Difference between revisions

Line 403:
# Optional parameters can be in any order, in any combination.
backup 'myfile', :follow-symlinks, :limit(2), :ext('bak');</lang>
 
=={{header|Phix}}==
{{trans|Go}}
<lang Phix>targetfile = "test.txt"
if not rename_file(targetfile, targetfile&".bak", overwrite:=true) then
puts(1,"warning: could not rename file\n")
end if
integer fn = open(targetfile,"w")
if fn=-1 then
puts(1,"error: cannot open file for writing\n")
else
puts(fn,"this task was translated from the Python entry\n")
close(fn)
end if</lang>
Before basing anything on the above code, though, I would recommend you take a look at <br>
function saveFile in demo\edix\edix.exw, which does this sort of thing for real: <br>
test.txt -> test.0001.txt, test.0002.txt, etc, in subdirectories \backups, \backups.0001, \backups.0002, etc.
 
=={{header|PicoLisp}}==
7,795

edits