Class RTS_File
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
RTS_Bytefile
,RTS_Imagefile
System class File.
class file(FILENAME); value FILENAME; text FILENAME; begin Boolean OPEN; text procedure filename; filename :- copy(FILENAME); Boolean procedure isopen; isopen := OPEN; Boolean procedure setaccess(mode); text mode; ... 10.1.1; if FILENAME = notext then error("..."); end file;
"File" is the common prefix class for all input/output classes.
A file is either open or inaccessible as indicated by the variable "OPEN". The procedure "isopen" returns the current value of "OPEN". A file is initially inaccessible (e.g. closed).
Each file object has a text attribute FILENAME. This text value must at "open" identify an external file which, through an implementation-defined mechanism, becomes associated with the file object. If the parameter value is notext, a run-time error occurs.
The procedure "filename" retrieves the value of FILENAME.
Link to GitHub: Source File.
- Author:
- SIMULA Standards Group, Øystein Myhre Andersen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enum
CREATE: Action is performed at 'open' -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
The output to the file is added to the existing contents of the file.protected boolean
If the value is true, input operations can be performed.protected boolean
If the value is true, output operations can be performed.protected Charset
The current character set when encode/decode files.protected RTS_File._CreateAction
CREATE: Action is performed as 'open'protected final int
The default BYTESIXE is 8 in this implementation.protected boolean
The OPEN indicator.protected boolean
PURGE: Action is performed at 'close'protected boolean
The access mode SYNCHRONOUS.protected final RTS_TXT
The file name.Fields inherited from class simula.runtime.RTS_ENVIRONMENT
_STARTTIME, CURRENTDECIMALMARK, CURRENTLOWTEN, EXCEPTION_HANDLER, maxint, maxlongreal, maxreal, minint, minlongreal, minreal, simulaReleaseID
Fields inherited from class simula.runtime.RTS_RTObject
_CORUT, _CTX, _CUR, _DL, _INPUT_LINELENGTH, _JTX, _OUTPUT_LINELENGTH, _SL, _STATE, _SYSIN, _SYSOUT, _USR, startTimeMs
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription_STM()
Method representing the Statements in this Block
This method is virtual and must be redefined in blocks.protected File
Do the Create action.protected void
Do the Purge actionfilename()
Returns the filename.boolean
isopen()
Returns true when this file is open.boolean
External file access control.protected boolean
setCharset
(String id) Set new Charset.protected void
TRACE_OPEN
(String mss) Utility: Trace file open.protected File
trySelectFile
(String fileName) Try to select a file named 'fileName'.Methods inherited from class simula.runtime.RTS_BASICIO
terminate_program, toString
Methods inherited from class simula.runtime.RTS_ENVIRONMENT
_char, abs, abs, abs, addepsilon, addepsilon, arccos, arcsin, arctan, arctan2, argv, blanks, Char, clocktime, copy, cos, cosh, cotan, cputime, datetime, decimalmark, DEFEXCEPTION, digit, discrete, draw, edfix, edfix, edit, edit, edit, edit, edit, edit, edtime, edtime, entier, Erlang, error, exit, exp, hash, histd, histo, isochar, isorank, letter, linear, ln, loadChar, log10, lowcase, lowerbound, lowten, max, max, max, max, max, max, max, max, max, max, max, min, min, min, min, min, min, min, min, min, min, min, mod, negexp, normal, Poisson, printStaticChain, printThreadList, randint, rank, rem, sign, simulaid, sin, sinh, sqrt, storeChar, subepsilon, subepsilon, tan, tanh, uniform, upcase, upperbound, waitSomeTime
Methods inherited from class simula.runtime.RTS_RTObject
_GOTO, _JUMPTABLE, _SIM_LABEL, _TREAT_GOTO_CATCH_BLOCK, _VALUE, arrayValue, BBLK, booleanValue, call, call, charValue, CONC, detach, detach, detach, doubleValue, EBLK, edObjectAttributes, edObjectIdent, floatValue, intValue, isDetachUsed, isQPSystemBlock, objectTraceIdentifier, objectTraceIdentifier, objectValue, procValue, resume, resume, resume, swapCoroutines, sysin, sysout, TRACE_GOTO
-
Field Details
-
FILE_NAME
The file name. -
_OPEN
protected boolean _OPENThe OPEN indicator. -
_CREATE
CREATE: Action is performed as 'open' -
_PURGE
protected boolean _PURGEPURGE: Action is performed at 'close'
The value "purge" implies that the external file may be deleted by the environment when it is closed (in the sense that it becomes inaccessible to further program access). The value "nopurge" implies no such deletion.
-
_CANREAD
protected boolean _CANREADIf the value is true, input operations can be performed.
This mode is relevant only for direct files.
-
_CANWRITE
protected boolean _CANWRITEIf the value is true, output operations can be performed.
This mode is relevant only for direct files.
-
_APPEND
protected boolean _APPENDThe output to the file is added to the existing contents of the file.
If the value is true, output to the file is added to the existing contents of the file. The value false implies for a sequential file that, after "close", the external file will contain only the output produced while the file was open.
The mode is not relevant for in(byte)files.
-
_CHARSET
The current character set when encode/decode files. -
_DEFAULT_BYTESIZE
protected final int _DEFAULT_BYTESIZEThe default BYTESIXE is 8 in this implementation.- See Also:
-
_SYNCHRONOUS
protected boolean _SYNCHRONOUSThe access mode SYNCHRONOUS.
It is available for Out- files and Direct- files. For Outfile/OutBytefile, each write operation will be followed by a flush to ensure that the underlying storage device is updated. For Directfile/DirectBytefile the underlaying Java RandomAccessFile will be created open for reading and writing, and also require that every update to the file's content or metadata be written synchronously to the underlying storage device.
-
-
Constructor Details
-
RTS_File
Create a new _File.- Parameters:
SL
- staticLinkFN
- file name
-
-
Method Details
-
_STM
Description copied from class:RTS_RTObject
Method representing the Statements in this Block
This method is virtual and must be redefined in blocks.- Overrides:
_STM
in classRTS_RTObject
- Returns:
- a pointer to this _RTObject
-
filename
-
isopen
public boolean isopen()Returns true when this file is open.- Returns:
- true when this file is open
-
trySelectFile
Try to select a file named 'fileName'.
If no file exists with that fileName it will try several possibilities:
- First it will search the Option.internal.RUNTIME_USER_DIR
- Second, system properties "user.dir" and "java.class.path".parent.
- Finally, a JFileChooser dialog is opened to let the user select the file.
- Parameters:
fileName
- the given fale name- Returns:
- the resulting file or null
-
setaccess
External file access control.
Certain attributes (not specified in the file outline) control the access to the external file. The values of these attributes are set when the file object is opened or closed, from a set of default values possibly modified by successive calls to the procedure "setaccess".
The standard attribute modes are SHARED, APPEND, CREATE, READWRITE, BYTESIZE, REWIND and PURGE.
The parameter "mode" to procedure "setaccess" contains one of the standard values as given above, namely "shared", "noshared", "append", "noappend", "create", "nocreate", "anycreate", "readonly", "writeonly", "readwrite", "bytesize:X" (where X is a positive integer), "rewind", "norewind", "purge" and "nopurge".
It is recommended that implementation-defined parameter values have the percent character % as the first character of the text.
Unrecognized modes are ignored and "setaccess" then returns the value false. The value is true otherwise.
The default values of the access modes are given in table 10.1, where "NA" means "not applicable" (i.e. ignored for this file kind) and "*" means that the value is implementation-defined.
Files of kind Mode: In- Out- Direct- Takes effect at SHARED shared noshared noshared open APPEND NA noappend noappend open CREATE NA anycreate nocreate open READWRITE NA NA readwrite open BYTESIZE:x * * * open REWIND norewind norewind NA open,close PURGE nopurge nopurge nopurge close
See Simula Standard Chapter 10, INPUT-OUTPUT.
- Parameters:
mode
- the access mode text- Returns:
- true if mode is recognized, otherwise false.
-
setCharset
Set new Charset.- Parameters:
id
- charset identifier- Returns:
- true if the operation was successful, otherwise false
-
doCreateAction
-
doPurgeAction
protected void doPurgeAction()Do the Purge action -
TRACE_OPEN
-