Class FileAction
File Action.
Link to GitHub: Source File.
- Author:
- Simula Standard, S-Port: The Environment Interface, Øystein Myhre Andersen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumCREATE: Action is performed at 'open' -
Field Summary
FieldsModifier and TypeFieldDescriptionbooleanThe output to the file is added to the existing contents of the file.booleanIf the value is true, input operations can be performed.booleanIf the value is true, output operations can be performed.protected CharsetThe current character set when encode/decode files.CREATE: Action is performed as 'open'protected final intThe default BYTESIZE is 8 in this implementation.booleanPURGE: Action is performed at 'close'booleanThe access mode SYNCHRONOUS. -
Constructor Summary
ConstructorsConstructorDescriptionFileAction(String action) Construct and decode a new FileAction based upon the given 'action' string. -
Method Summary
Modifier and TypeMethodDescriptionprivate voiddecodeActions(String action) Decode the given 'action' string.doCreateAction(String fileName) Do the Create action.voiddoPurgeAction(String fileName) Do the Purge actionprivate intgetActionChar(String action, int idx) Utility: to pick up a character from the 'action' stringprotected FiletrySelectFile(String fileName) Try to select a file named 'fileName'.
-
Field Details
-
_CREATE
CREATE: Action is performed as 'open' -
_PURGE
public 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
public boolean _CANREADIf the value is true, input operations can be performed.
This mode is relevant only for direct files.
-
_CANWRITE
public boolean _CANWRITEIf the value is true, output operations can be performed.
This mode is relevant only for direct files.
-
_APPEND
public 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 BYTESIZE is 8 in this implementation.- See Also:
-
_SYNCHRONOUS
public 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
-
FileAction
Construct and decode a new FileAction based upon the given 'action' string.- Parameters:
action- the action string
-
-
Method Details
-
decodeActions
Decode the given 'action' string.
action encoding: (a digit gives the rank of the character, e.g. 0 is NUL) action == <0 ! 1 > -- shared/noshared <0 ! 1 > -- append/noappend <0 ! 1 ! 2 > -- create/nocreate/anycreate <0 ! 1 ! 2 > -- readonly/writeonly/readwrite <0 ! 1 > -- purge/nopurge <0 ! 1 ! 2 ! 3 ! 4 ! 5 > -- rewind/norewind/next/previous/repeat/release <> -- bytesize: rank(char) (!0! default) < > -- move: ( )* -- unknown access modes 0 -- terminating NUL character The action string will always be at least 10 chars long, encoded with the predefined modes in the above given sequence (e.g. char number 3 will always specify the CREATE mode). If no value is given for some mode, RTS will insert the appropriate default character at the relevant position. These defaults are:
in(byte)file: "!0!!1!!1!!0!!1!!2!!0!!0!!0!!0!!0!" out(byte)file: "!1!!1!!2!!1!!1!!2!!0!!0!!0!!0!!0!" direct(byte)file: "!1!!1!!1!!2!!1!!5!!0!!0!!0!!0!!0!"If an unknown (i.e. non-Sport-defined) value are given as parameter to procedure "setaccess", the first character must be '%' (percent), otherwise "setaccess" returns FALSE (in all other cases it is TRUE). Accepted values will be concatenated with the standard string, with '%' replaced by a character (l) whose rank gives the length of the string, excluding the overwritten '%'. The action string is always terminated by the NUL character ('!0!').
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- Parameters:
action- the action string
-
getActionChar
Utility: to pick up a character from the 'action' string- Parameters:
action- the action stringidx- the index- Returns:
- the requested character
-
doCreateAction
-
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 file name- Returns:
- the resulting file or null
-
doPurgeAction
-