Closed ghsnd closed 3 months ago
Related to https://github.com/kg-construct/rml-core/issues/113
What about adding to rml:Target
:
rml:mode
: the mode to use when accessing the fileThis property has the range of:
rml:Read
: read-only mode (r
). Start beginning of file. Not useful for targets. File must exist.rml:ReadWrite
: read-write mode (r+
). Start beginning of file, no truncation. Only write part is useful for targets. File must exist.rml:Write
: write mode (w
). Truncate/create file and start at the beginning to add new data.rml:WriteRead
: write-read mode (w
). Truncate/create file and start at the beginning to add new data. Only write part is useful for targetsrml:Append
: append-only mode. Existing file is kept and new data is appended at the end. File is created if not exist.rml:AppendRead
: append-read mode. Existing file is kept and new data is appended at the end. File is created if not exist.These semantics are derived from fopen()
:
``r'' Open text file for reading. The stream is positioned at the
beginning of the file.
``r+'' Open for reading and writing. The stream is positioned at the
beginning of the file.
``w'' Truncate to zero length or create text file for writing. The
stream is positioned at the beginning of the file.
``w+'' Open for reading and writing. The file is created if it does not
exist, otherwise it is truncated. The stream is positioned at
the beginning of the file.
``a'' Open for writing. The file is created if it does not exist. The
stream is positioned at the end of the file. Subsequent writes
to the file will always end up at the then current end of file,
irrespective of any intervening [fseek(3)](https://www.manpagez.com/man/3/fseek/) or similar.
``a+'' Open for reading and writing. The file is created if it does not
exist. The stream is positioned at the end of the file. Subse-
quent writes to the file will always end up at the then current
end of file, irrespective of any intervening [fseek(3)](https://www.manpagez.com/man/3/fseek/) or similar.
Source: https://www.manpagez.com/man/3/fopen/
If no access mode is provided, the file is opened in rml:Write
mode for rml:Target
.
Note: rml:Source
does have rml:mode
since it always open the source in read-only mode.
For some targets it might make sense to specify some extra properties. I have this use case where I want to append output to target file x, but overwrite target file y if it exists. So for files there are the typical write modes, e.g. like the python file modes
w
,a
, etc.In the spec these properties might translate to properties that apply to other kinds of targets as well, for instance databases.