2018-04-12 09:04:16 +10:00
|
|
|
"sys-filewrap" is responsible for
|
|
|
|
wrapping a filesystem object with a
|
|
|
|
file-like mechanism.
|
|
|
|
|
|
|
|
It simply provides two functions:
|
|
|
|
ensureMode(mode): Ensures that a
|
|
|
|
mode is valid, and translates it.
|
|
|
|
create(dev, file, mode):
|
|
|
|
Open a file using a given proxy,
|
|
|
|
filename and mode.
|
|
|
|
|
|
|
|
The mode you give to it can be one of
|
|
|
|
the following:
|
|
|
|
false: Read "rb"
|
|
|
|
true: Write "wb"
|
|
|
|
"append": Append "ab"
|
|
|
|
May have some readability
|
2018-12-24 10:51:30 +11:00
|
|
|
properties - just in
|
2018-04-12 09:04:16 +10:00
|
|
|
case, I've added 'read',
|
|
|
|
but don't get your hopes
|
|
|
|
up...
|
2018-12-24 10:51:30 +11:00
|
|
|
"access": Like read, but can be
|
|
|
|
re-opened for write.
|
2018-04-12 09:04:16 +10:00
|
|
|
|
|
|
|
It returns two things - a table, that
|
|
|
|
being the file object, and the
|
|
|
|
'close' function from that object,
|
|
|
|
for closing the file without using
|
|
|
|
a potentially modifiable table.
|
|
|
|
|
|
|
|
If the table is nil, then the "close"
|
|
|
|
function is actually a string, that
|
|
|
|
being the error.
|
|
|
|
|
|
|
|
The possible functions are:
|
|
|
|
[arw] close(): Closes the file.
|
|
|
|
[arw] seek(whence, pos): Seeks in
|
|
|
|
the file.
|
|
|
|
[aw] write(data): Writes to the
|
|
|
|
file.
|
|
|
|
[arw] read(data): Reads from the
|
2018-12-24 10:51:30 +11:00
|
|
|
file. data is the byte count.
|
|
|
|
However, "*a" is valid here.
|
|
|
|
Other string-based options are not.
|
2018-04-12 09:04:16 +10:00
|
|
|
|
|
|
|
NOTE: Some of these may not actually
|
|
|
|
work. They're just there as more or
|
|
|
|
less a "do no harm" approach.
|
|
|
|
|
|
|
|
-- This is released into
|
|
|
|
the public domain.
|
|
|
|
-- No warranty is provided,
|
|
|
|
implied or otherwise.
|