Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
19
Task/File-input-output/Clean/file-input-output-1.clean
Normal file
19
Task/File-input-output/Clean/file-input-output-1.clean
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import StdEnv
|
||||
|
||||
copyFile fromPath toPath world
|
||||
# (ok, fromFile, world) = fopen fromPath FReadData world
|
||||
| not ok = abort ("Cannot open " +++ fromPath +++ " for reading")
|
||||
# (ok, toFile, world) = fopen toPath FWriteData world
|
||||
| not ok = abort ("Cannot open " +++ toPath +++ " for writing")
|
||||
# (fromFile, toFile) = copyData 1024 fromFile toFile
|
||||
# (ok, world) = fclose fromFile world
|
||||
| not ok = abort ("Cannot close " +++ fromPath +++ " after reading")
|
||||
# (ok, world) = fclose toFile world
|
||||
| not ok = abort ("Cannot close " +++ toPath +++ " after writing")
|
||||
= world
|
||||
where
|
||||
copyData bufferSize fromFile toFile
|
||||
# (buffer, fromFile) = freads fromFile bufferSize
|
||||
# toFile = fwrites buffer toFile
|
||||
| size buffer < bufferSize = (fromFile, toFile) // we're done
|
||||
= copyData bufferSize fromFile toFile // continue recursively
|
||||
1
Task/File-input-output/Clean/file-input-output-2.clean
Normal file
1
Task/File-input-output/Clean/file-input-output-2.clean
Normal file
|
|
@ -0,0 +1 @@
|
|||
Start world = copyFile "input.txt" "output.txt" world
|
||||
Loading…
Add table
Add a link
Reference in a new issue