FileAccessor contains a common basis for ReadAccessor and WriteAccessor. It provides methods for checking and setting the current position in the file (GetPosition, Set Position, MovePosition, IsEof) and for checking the current size of the file (GetSize).
Serves as a common base class for file size queries and position navigation for specialized file accesses.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: e1768b56d42cProvenanceOpen questions (2)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
Serves as a common base class for file size queries and position navigation for specialized file accesses.
The class ara::per::FileAccessor serves in the AUTOSAR Persistency module as a common base class for position navigation and size checking of ordered file accesses ([SWS_PER_00424]). It prevents direct instantiation as well as copy operations through deleted constructors ([SWS_PER_00589]). In the event of invalid position specifications, rollback semantics take effect that protect the current pointer position. All operations are exception-safe, but require external synchronization in concurrent use.
Context
The class ara::per::FileAccessor serves in the Persistency module (ara::per) of the AUTOSAR Adaptive Platform as a common abstract base class for file access objects such as ReadAccessor and WriteAccessor. Its central responsibility is the uniform interface for file-related position management and size checking. The class functions as a controlling instance for the read and write cursor within an open file, but does not itself contain methods for actual data transfer (such as reading or writing bytes). Navigation is performed either absolutely from the beginning of the file or relatively to defined reference points.
Lifecycle
The class ara::per::FileAccessor cannot be instantiated directly or freely copied. The default constructor is deleted ([SWS_PER_00589]), as are the copy constructor ([SWS_PER_00592]) and the copy assignment operator ([SWS_PER_00593]). Move semantics are explicitly prevented as well: both the move constructor ([SWS_PER_00590]) and the move assignment operator ([SWS_PER_00591]) are deleted. This leads to the interpretation that instances are created and managed exclusively in the context of concrete subclasses.
Safe release is ensured by the virtual destructor ~FileAccessor() ([SWS_PER_00594]), which enables polymorphic destruction via base class pointers. Regarding concurrency, all member functions are specified as not thread-safe ([SWS_PER_00162], [SWS_PER_00424], [SWS_PER_00107], [SWS_PER_00163], [SWS_PER_00164]). Competing accesses from different threads to the same instance must consequently be synchronized by the application.
Usage Path
Typical use of FileAccessor comprises querying the file size, determining the current position, and targeted position offsets in preparation for read or write accesses:
Size query: The current file size in bytes is determined via GetSize() ([SWS_PER_00424]).
Position query: Using GetPosition(), the application queries the current byte offset from the beginning of the file, which may also be located exactly at the end of the file ([SWS_PER_00162]).
Absolute positioning:SetPosition() sets the cursor to an absolute offset from the beginning of the file ([SWS_PER_00163]).
Relative offset:MovePosition() moves the cursor by a signed offset starting from Origin::kBeginning, Origin::kCurrent, or Origin::kEnd ([SWS_PER_00164]).
End-of-file check: The method IsEof() indicates whether the current position has reached the end of the file ([SWS_PER_00107]).
All operations of FileAccessor are declared exception-safe (noexcept). Potential error conditions during navigation calls are returned via ara::core::Result:
If an application attempts to navigate to a position beyond the end of the file via SetPosition(), the call fails with error code PerErrc::kInvalidPosition ([SWS_PER_00163]). The same applies to MovePosition() if the calculated target position would be negative or lies beyond the end of the file ([SWS_PER_00164]). Strict rollback semantics are mandatory for both methods: if an error occurs, the previously valid position of the file remains unchanged ([SWS_PER_00163], [SWS_PER_00164]).
The query methods GetSize() ([SWS_PER_00424]), GetPosition() ([SWS_PER_00162]), and IsEof() ([SWS_PER_00107]) directly return basic data types and do not generate specific error codes.
An AI wrote this text based on the AUTOSAR specification R25-11. It supplements the normative documentation with an overall picture of the navigation abstraction.
Moves the current position in the file relative to the Origin. In case of an error, the current position is not changed.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 436bd0736ae4Provenance
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
use
The synchronous method MovePosition of class ara::per::FileAccessor moves the current file position relative to a defined reference point [SWS_PER_00164]. The function is declared as noexcept[SWS_PER_00164]. As parameters, it takes the base point origin of type Origin and the signed byte offset offset[SWS_PER_00164]. Upon successful execution, the method returns a ara::core::Result with the resulting absolute byte position from the beginning of the file [SWS_PER_00164].
Interaction and Parameter Values
The reference point origin is determined by the enumeration Origin[SWS_PER_00146]:
Origin::kBeginning: Offset from the beginning of the file; offset can be positive here [SWS_PER_00164], [SWS_PER_00146].
Origin::kCurrent: Offset from the current file position; offset may be positive or negative, where a value of zero does not change the position [SWS_PER_00164], [SWS_PER_00146].
Origin::kEnd: Offset relative to the end of the file; offset may be negative, while an offset of zero sets the position exactly to the end of the file [SWS_PER_00164], [SWS_PER_00146].
Error handling
In the event of an error, the previous file position is not changed due to rollback semantics [SWS_PER_00164]. If the calculated target point results in a value less than zero or lies beyond the end of the file, the error code PerErrc::kInvalidPosition is returned [SWS_PER_00164]. In addition, the result may contain vendor-specific errors [SWS_PER_00164].
Concurrency and Limitations
The method is specified as exception safe[SWS_PER_00164]. Since the implementation is classified as not thread-safe, parallel accesses to the same instance of FileAccessor must be synchronized on the caller side [SWS_PER_00164].
This text was created by an AI system and curated by autodocs.
Offset in bytes relative to ’origin’. Can be positive in case of k Beginning and kCurrent and negative in case of kCurrent and k End. In case of kCurrent, an offset of zero will not change the current position. In case of kEnd, an offset of zero will set the position to the end of the file.
A Result containing the new position in bytes from the beginning of the file. In case of an error, it contains any of the errors defined below, or a vendor specific error.
gemini-3.8-flash-low· 2026-10-13 · German original