Hello,
i want to use io.open() to create and edit a text-file. First there should be create a new file in the given path or overwrite an existing one. After i want to continuously add some text to this file.
where can i find an explanation for the second parameter of the function which controlls the behaviour of the file. (r/w/a/w+/a+)
cheers
Parameters io.open()
Re: Parameters io.open()
Hello,
The second parameter in io.open() specifies the file mode, which controls how the file is opened and how you can interact with it:
The second parameter in io.open() specifies the file mode, which controls how the file is opened and how you can interact with it:
- "r": Read mode (default). Opens the file for reading. Fails if the file does not exist.
- "w": Write mode. Creates a new file or overwrites an existing file.
- "a": Append mode. Opens a file for writing without overwriting existing content.
- "r+": Read and write mode. The file must exist.
- "w+": Read and write mode. Creates a new file or overwrites an existing file.
- "a+": Read and append mode. Opens a file for reading and writing, keeping existing content intact.