Random Access File Functions

For those of you who don’t know what I’m talking about: http://en.wikipedia.org/wiki/Random_access

Any addon that has reason to start reading data from a file at a specific point or to write data to a specific point would greatly benefit from the inclusion of random access functions in the file library. Not to mention it could make the filex.Append function less of a joke.

@Those who think random access is only for binary data:

  1. You make me laugh.
  2. The only real difference between binary and text data is how you work with it programmatically.

I see no use for this. Could you explain anything specific which could be created or improved by such functions?

This wouldn’t help. I mean, think about it. This requires the creator of the addon to specify where in the file the data is. Additionally, that would require quite a lot of work on Garry’s part. It’s not worth the effort.

[editline]01:14PM[/editline]

Lua can’t read null bytes, and will stop reading a file as soon as it comes across one. The only benefit of this would be skipping the null byte, allowing you to read the binary data.

[ol]
[li]The filex.Append function, as mentioned in the OP. Currently, it’s just a helper function that loads the entire file to memory, concatenates the given data, and then overwrites the file.[/li][li]ULX/etc. logging.[/li][li]Adv. Duplicator could display the creator/description contained in a dupe file without having to load the entire file.[/li][li]Pretty much anything with reason to access only part of a relatively large file.[/li][/ol]

What are you trying to say? If you mean when accessing, that’s the point of random access.

LOL no, no it wouldn’t; if Garry can code a game, he can implement random access for files. It’s taught in semester-long beginning-level high school programming courses as a basic skill.