How about variations on the OPEN statement so one could check for the
needed permissions up front:
OPENR - open for read only
OPENW - open for write only
OPENRW - open for read & write
(OPEN - same as today for backward compatibility)
the ELSE clause would taken if you don't have the required permission.
If you subsequently attempt to either read or write, but haven't opened
it properly, you'd error out similar to when the file-variable is
undefined.
----
But even without this, on UV some of your concerns can be addressed
already.
1. STATUS statement can show you ahead of time what permission you have.
A higher-level function or subr would be in order, but down & dirty it's
this on unix:
OPEN xxxx TO FVAR ELSE STOP
STATUS FSTAT FROM FVAR ELSE STOP
CRT 'MODE = ': OCONV( FSTAT<5>, 'MO' ) ;* octal
If it prints "100640"
----> 640 octal
---> 110 100 000
--> rw- r-- ---
-> owner: can read & write
group: can read
other: no access
Next step is to figure out owner, group.
FSTAT<8> = owner no.
FSTAT<9> = group no.
FSTAT<30> = owner name
& if the current user is either.
2. To avoid fatal errors on illegal writes, WRITE has ELSE and ON ERROR
clauses available to it, that, if they exist, will get executed.
3. uv/errlog also contains entries for fatal errors.
Would these approaches satify?
-----Original Message-----
From: Susan Joslyn
When a BASIC program in either U2 flavor attempts a write to a file that
cannot be written to the program bombs completely out to TCL and no
information is given about the file, nor about the specifics (is it the
owner, the group, the RWX permissions?).
There are system commands in both flavors that can be used to query a
file's write-ability before attempting the WRITE. Before I go try to
find every write in the system and put that check into place, I'm
wondering why can't the write itself do this? Ideally not bomb out of
the program, but even if that is hard to correct, reporting the NAME OF
THE FILE that couldn't be written to would save many hours of system
scouring!
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/