mirror of
https://github.com/20kdc/OC-KittenOS.git
synced 2024-12-27 03:18:06 +11:00
0d9583fcff
This isn't getting pushed until AmandaC's tested it. I'm not sure this is such a good idea, anyway ; if it's for load/save workflow improvements, wouldn't it be better to have a file access method that allows for file re-opening? That said, there's a limit to *that* before you just have to say, "Just use /data/".
54 lines
1.3 KiB
Plaintext
54 lines
1.3 KiB
Plaintext
"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
|
|
properties - just in
|
|
case, I've added 'read',
|
|
but don't get your hopes
|
|
up...
|
|
"access": Like read, but can be
|
|
re-opened for write.
|
|
|
|
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
|
|
file. data is the byte count.
|
|
However, "*a" is valid here.
|
|
Other string-based options are not.
|
|
|
|
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.
|