![]() |
VSM C++ SDK
Vehicle Specific Modules SDK
|
Processor for working with filesystem I/O. More...
#include <file_processor.h>
Classes | |
struct | Already_exists_exception_dummy_struct |
File already exists. More... | |
class | Native_controller |
Interface for native I/O controller which manages I/O operations for all native handles. More... | |
struct | Not_found_exception_dummy_struct |
File not found. More... | |
struct | Permission_denied_exception_dummy_struct |
Permission denied. More... | |
class | Stream |
Stream class which represents opened file. More... | |
Public Member Functions | |
VSM_DEFINE_EXCEPTION (Exception) | |
Base class for all File_processor exceptions. More... | |
Stream::Ref | Open (const std::string &name, const std::string &mode, bool maintain_pos=true) |
Open file. More... | |
![]() | |
virtual Type | Get_type () const override |
Get this container type. More... | |
![]() | |
Request_container (const std::string &name, Request_waiter::Ptr waiter=Request_waiter::Create()) | |
Create container with default associated waiter. More... | |
bool | Check_type (Type mask) |
Check if the container type conforms the specified characteristic mask. More... | |
void | Submit_request (Request::Ptr request) |
Submit request to this container for further processing or notification handlers invocation. More... | |
void | Submit_request_locked (Request::Ptr request, Request_waiter::Locker locker) |
The same as Submit_request, but with previously acquired lock of the associated waiter. More... | |
int | Process_requests (int requests_limit=0) |
Process all currently queued requests. More... | |
int | Process_requests (std::unique_lock< std::mutex > &lock, int requests_limit=0) |
Process all currently queued requests. More... | |
void | Set_waiter (Request_waiter::Ptr waiter) |
Set request waiter associated with this container. More... | |
Request_waiter::Ptr | Get_waiter () const |
Get request waiter associated with this container. More... | |
const std::string & | Get_name () |
Get the name of the container. More... | |
void | Enable () |
Enable the container. More... | |
void | Disable () |
Disable the container. More... | |
bool | Is_enabled () const |
Check if the container is currently enabled. More... | |
Static Public Member Functions | |
template<typename... Args> | |
static Ptr | Create (Args &&...args) |
Create an instance. More... | |
template<typename... Args> | |
static Ptr | Get_instance (Args &&...args) |
Get global or create new processor instance. More... | |
static FILE * | Fopen_utf8 (const std::string &name, const std::string &mode) |
Platform independent method for opening a standard library file handle providing an UTF-8 encoded path and mode. More... | |
static bool | Rename_utf8 (const std::string &old_name, const std::string &new_name) |
Platform independent method for renaming a file providing UTF-8 encoded paths. More... | |
static bool | Remove_utf8 (const std::string &name) |
Platform independent method for removing a file providing UTF-8 encoded path. | |
static int | Access_utf8 (const std::string &name, int mode) |
Platform independent method for checking file access permission providing UTF-8 file name. More... | |
![]() | |
template<typename... Args> | |
static Ptr | Create (Args &&...args) |
Create an instance. More... | |
![]() | |
template<typename... Args> | |
static Ptr | Create (Args &&...args) |
Create an instance. More... | |
Protected Member Functions | |
void | Register_stream (File_processor::Stream::Ptr) |
Register opened stream in a processor. More... | |
![]() | |
void | Processing_loop () |
Request processing loop implementation. More... | |
void | Set_disabled () |
Disable the container and notify its waiter. More... | |
virtual void | On_wait_and_process () |
Called when default processing loop want to wait for work and process it. More... | |
Friends | |
class | Stream |
Additional Inherited Members | |
![]() | |
Request_waiter::Ptr | waiter |
Waiter associated with this container. More... | |
std::list< Request::Ptr > | request_queue |
Queue of pending requests, i.e. More... | |
Processor for working with filesystem I/O.
It is mostly intended for working with special files such as mapped devices in asynchronous mode. It is not so useful for regular files so the user code can use <cstdio> functions for them (unless it does not need asynchronous file operations). Keep in mind that this processor provides asynchronous I/O but not concurrent. All operations for each stream are serialized and never executed in parallel. In case the client code issues concurrent requests it should be aware that file position can be unpredictably updated unless it is explicitly specified.
typedef ugcs::vsm::Derived_exception< Exception , Already_exists_exception_dummy_struct> ugcs::vsm::File_processor::Already_exists_exception |
Definition of a new exception type.
typedef ugcs::vsm::Derived_exception< Exception , Not_found_exception_dummy_struct> ugcs::vsm::File_processor::Not_found_exception |
Definition of a new exception type.
typedef ugcs::vsm::Derived_exception< Exception , Permission_denied_exception_dummy_struct> ugcs::vsm::File_processor::Permission_denied_exception |
Definition of a new exception type.
|
static |
Platform independent method for checking file access permission providing UTF-8 file name.
name | UTF-8 encoded file name. |
mode | Mode as in standard access() method. |
|
inlinestatic |
Create an instance.
|
static |
Platform independent method for opening a standard library file handle providing an UTF-8 encoded path and mode.
name | UTF-8 encoded file path to open. |
mode | UTF-8 encoded access mode, see standard fopen() method. |
|
inlinestatic |
Get global or create new processor instance.
Stream::Ref ugcs::vsm::File_processor::Open | ( | const std::string & | name, |
const std::string & | mode, | ||
bool | maintain_pos = true |
||
) |
Open file.
name | File path. |
mode | Opening mode similar to the corresponding argument for fopen() function. It supports "x" specifier and do not support "a" and "b" specifiers. All files are opened in binary mode. NOTE: In addition "rx" combination is supported and means create file in read-only mode if it does not exist. |
maintain_pos | Indicates whether file position maintenance is required. It should be "false" for devices which do not support seeking. In this case file offset for all I/O operations will be set to zero. In case it is "true" the returned file stream will maintain current position accordingly to the number of bytes read or written. |
Invalid_param_exception | if mode string is not valid. |
Not_found_exception | if the specified path does not exist when it must exist based on provided opening mode. |
Permission_denied_exception | if there is insufficient permissions for file creation. |
Already_exists_exception | if new file creation requested ('x' specified in opening mode) but the file already exists. |
Exception | in case of any other error returned by platform. |
|
protected |
Register opened stream in a processor.
|
static |
Platform independent method for renaming a file providing UTF-8 encoded paths.
old_name | UTF-8 encoded old file name. |
new_name | UTF-8 encoded new file name; |
ugcs::vsm::File_processor::VSM_DEFINE_EXCEPTION | ( | Exception | ) |
Base class for all File_processor exceptions.