mirror of
https://github.com/20kdc/OC-KittenOS.git
synced 2024-11-17 07:58:06 +11:00
a5372eafe1
KTC1 is only a draft for now, and if there's something equivalent to replace it, I will not hesitate to do so.
50 lines
1.2 KiB
Plaintext
50 lines
1.2 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
|
|
propertiues - just in
|
|
case, I've added 'read',
|
|
but don't get your hopes
|
|
up...
|
|
|
|
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.
|
|
|
|
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.
|