The File concept abstracts access to files in the underlying file system. Two implementations are provided, one for the Win32 API and the other for POSIX compliant systems. The native_file type alias is automatically set to either win32_file or posix_file as appropriate.
To support interfaces other than Win32 or POSIX, callers may provide their own File type that meets these requirements. The unit test code also provides its own File type which causes simulated operating system file failures to exercise all failure paths in the implementation.
In the table below:
X
denotes a File type
a
and b
denote values of type X
c
denotes a (possibly
const) value of type X
m
denotes a value of
type file_mode
f
denotes a value of
type path_type
q
denotes a value of
type void*
p
denotes a value of
type void const*
ec
denotes a value of
type error_code
o
denotes a value of
type std::uint64_t
n
denotes a value of
type std::size_t
Table 1. File requirements
operation |
type |
semantics, pre/post-conditions |
---|---|---|
|
|
|
|
|
Returns |
|
If |
|
|
Attempts to create a file at the path specified by |
|
|
Attempts to open the file at the path specified by |
|
|
Attempts to delete the file at the path specified by |
|
|
|
Returns the size of the file in bytes. This value is also equal
to lowest byte offset for which a read will always return a short_read error. Undefined behavior
if |
|
Attempts to read |
|
|
Attempts to write |
|
|
Attempts to synchronize the file on disk. This instructs the operating
system to ensure that any data which resides in caches or buffers
is fully written to the underlying storage device before this call
returns. If an error occurs,
NuDB's database integrity guarantees are only valid if the implementation
of |
|
|
Attempts to change the size of the open file referred to by
NuDB's database integrity guarantees are only valid if the implementation
of |