V
V
Vadim Ushakov2021-12-18 01:11:10
File systems
Vadim Ushakov, 2021-12-18 01:11:10

Write to a file starting at a certain position?

Um, ... strange, but. In general, there is a code fragment, and it does not work, I don’t know why, but I need it to work.

file = io.open(exepath, "a+b")
local fsz = file:seek"end"
print(fsz, datablc)
file:seek("set", math.min(fsz, datablc))
file : write("THE TEST POSITIONED DATA!")
file : close()


Why doesn't it work and how to fix it? There is, of course, the option of reading the entire content of the file into a variable and the sub method, but there is a seek function. How ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim Ushakov, 2021-12-18
@Nightmare1

Changed the file open mode to r+b and it worked. Now the question is different, how to erase, i.e. delete a fragment from a file in the same mode?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question