Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
34
Task/File-input-output/Lingo/file-input-output-1.lingo
Normal file
34
Task/File-input-output/Lingo/file-input-output-1.lingo
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
----------------------------------------
|
||||
-- Returns file as ByteArray
|
||||
-- @param {string} tFile
|
||||
-- @return {byteArray|false}
|
||||
----------------------------------------
|
||||
on getBytes (tFile)
|
||||
fp = xtra("fileIO").new()
|
||||
fp.openFile(tFile, 1)
|
||||
if fp.status() then return false
|
||||
data = fp.readByteArray(fp.getLength())
|
||||
fp.closeFile()
|
||||
return data
|
||||
end
|
||||
|
||||
----------------------------------------
|
||||
-- Saves ByteArray to file
|
||||
-- @param {string} tFile
|
||||
-- @param {byteArray} tString
|
||||
-- @return {bool} success
|
||||
----------------------------------------
|
||||
on putBytes (tFile, tByteArray)
|
||||
fp = xtra("fileIO").new()
|
||||
fp.openFile(tFile, 2)
|
||||
err = fp.status()
|
||||
if not (err) then fp.delete()
|
||||
else if (err and not (err = -37)) then return false
|
||||
fp.createFile(tFile)
|
||||
if fp.status() then return false
|
||||
fp.openFile(tFile, 2)
|
||||
if fp.status() then return false
|
||||
fp.writeByteArray(tByteArray)
|
||||
fp.closeFile()
|
||||
return true
|
||||
end
|
||||
2
Task/File-input-output/Lingo/file-input-output-2.lingo
Normal file
2
Task/File-input-output/Lingo/file-input-output-2.lingo
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
data = getBytes("input.txt")
|
||||
putBytes("output.txt", data)
|
||||
Loading…
Add table
Add a link
Reference in a new issue