13 lines
489 B
Text
13 lines
489 B
Text
local filename = "temp.txt"
|
|
|
|
-- Create a file of length 26 bytes.
|
|
io.contents(filename, "abcdefghijklmnopqrstuvwxyz")
|
|
print($"Contents before truncation: {io.contents(filename)}")
|
|
|
|
-- Truncate file to 13 bytes.
|
|
io.contents(filename, io.contents(filename):sub(1, 13))
|
|
print($"Contents after truncation : {io.contents(filename)}")
|
|
|
|
-- Attempt to truncate file to 20 bytes.
|
|
io.contents(filename, io.contents(filename):sub(1, 20))
|
|
print($"Contents are still : {io.contents(filename)}")
|