2019-10-24 09:37:47 +00:00
|
|
|
class(#limited) InputOutputStud(Object) from "io"
|
|
|
|
{
|
2019-10-25 08:44:05 +00:00
|
|
|
var(#get) handle. // you must keep handle as the first field for consitency with the io module.
|
2019-10-24 09:37:47 +00:00
|
|
|
|
|
|
|
method(#primitive,#lenient) _close.
|
2019-10-29 14:21:14 +00:00
|
|
|
method(#primitive) _readBytesInto: buffer.
|
2019-10-24 09:37:47 +00:00
|
|
|
method(#primitive) _readBytesInto: buffer startingAt: offset for: count.
|
2019-10-29 14:21:14 +00:00
|
|
|
method(#primitive) _writeBytesFrom: buffer.
|
2019-10-24 09:37:47 +00:00
|
|
|
method(#primitive) _writeBytesFrom: buffer startingAt: offset for: count.
|
|
|
|
}
|
|
|
|
|
|
|
|
class FileAccessor(InputOutputStud) from "io.file"
|
|
|
|
{
|
2019-10-24 15:17:46 +00:00
|
|
|
pooldic Flag
|
|
|
|
{
|
2019-10-31 09:09:11 +00:00
|
|
|
LOCK_EX from "LOCK_EX",
|
|
|
|
LOCK_NB from "LOCK_NB",
|
|
|
|
LOCK_SH from "LOCK_SH",
|
|
|
|
LOCK_UN from "LOCK_UN",
|
|
|
|
|
2019-10-25 08:44:05 +00:00
|
|
|
//O_RDONLY := 0,
|
|
|
|
//O_WRONLY := 1
|
2019-10-26 02:04:36 +00:00
|
|
|
O_CLOEXEC from "O_CLOEXEC",
|
|
|
|
O_CREAT from "O_CREAT",
|
|
|
|
O_EXCL from "O_EXCL",
|
|
|
|
O_NOFOLLOW from "O_NOFOLLOW",
|
|
|
|
O_NONBLOCK from "O_NONBLOCK",
|
|
|
|
O_RDONLY from "O_RDONLY",
|
|
|
|
O_RDWR from "O_RDWR",
|
|
|
|
O_TRUNC from "O_TRUNC",
|
2019-10-29 14:21:14 +00:00
|
|
|
O_WRONLY from "O_WRONLY",
|
|
|
|
|
|
|
|
SEEK_CUR from "SEEK_CUR",
|
|
|
|
SEEK_END from "SEEK_END",
|
|
|
|
SEEK_SET from "SEEK_SET"
|
2019-10-24 15:17:46 +00:00
|
|
|
}
|
|
|
|
|
2019-10-24 09:37:47 +00:00
|
|
|
method(#primitive,#lenient) _open: path flags: flags.
|
2019-10-31 09:09:11 +00:00
|
|
|
method(#primitive) _chmod: mode.
|
|
|
|
method(#primitive) _chown: uid group: gid.
|
|
|
|
method(#primitive) _lock: opcode.
|
2019-10-29 14:21:14 +00:00
|
|
|
method(#primitive) _seek: offset whence: whence.
|
2019-10-31 09:09:11 +00:00
|
|
|
method(#primitive) _truncate: size.
|
2019-10-24 09:37:47 +00:00
|
|
|
|
|
|
|
method(#class) on: path for: flags
|
|
|
|
{
|
|
|
|
| fa |
|
|
|
|
fa := self new _open: path flags: flags.
|
2019-10-24 15:17:46 +00:00
|
|
|
if (fa isError) { self error: "Unable to open file %s - %s" strfmt(path, thisProcess primErrorMessage) }.
|
|
|
|
fa addToBeFinalized.
|
2019-10-24 09:37:47 +00:00
|
|
|
^fa.
|
|
|
|
}
|
|
|
|
|
|
|
|
method close
|
|
|
|
{
|
|
|
|
self _close.
|
|
|
|
self removeToBeFinalized.
|
|
|
|
}
|
|
|
|
|
|
|
|
method finalize
|
|
|
|
{
|
|
|
|
self close.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
class UnixFileAccessor(FileAccessor) from "io.file.unix"
|
|
|
|
{
|
|
|
|
method(#primitive) _open: path flags: flags mode: mode.
|
|
|
|
}
|
|
|
|
*/
|