Files CCore/inc/Scan.h CCore/src/Scan.cpp
Subfolders CCore/inc/scan CCore/src/scan
There are several classes for the scanning.
The class ScanAsyncFile can be used to scan async files.
class ScanAsyncFile : public ScanBase
{
....
private:
virtual PtrLen<const char> underflow();
public:
// constructors
explicit ScanAsyncFile(MSec timeout=DefaultTimeout,ulen max_packets=DefaultMaxPackets);
explicit ScanAsyncFile(StrLen file_name,MSec timeout=DefaultTimeout,ulen max_packets=DefaultMaxPackets);
ScanAsyncFile(StrLen dev_name,StrLen dev_file_name,MSec timeout=DefaultTimeout,ulen max_packets=DefaultMaxPackets);
~ScanAsyncFile();
// methods
bool isOpened() const;
void setFinalTimeout(MSec t);
void open(StrLen file_name);
void open(StrLen dev_name,StrLen dev_file_name);
void soft_close(FileMultiError &errout);
void close();
};
ScanAsyncFile object can be opened or closed. To scan from a particular file, the ScanAsyncFile object must be opened and the file name must be provided. It can be done using the constructor or the method open(). Default constructor creates an object in the closed state. Non-default opens a file. In case of error an exception is thrown. The file may be also specified using the device name and the device file name.
timeout is used as timeout on file read operations.
max_packets is the maximum number of packets are simultaneously used to read the file.
Destructor closes an opened object. Errors are reported.
isOpened() returns true, if the file is opened, and false otherwise.
open() opens a closed object with the given file name. In case of error an exception is thrown.
close() closes an opened object. In case of error and if there is a pending read error an exception is thrown.
soft_close() does not throw, it returns instead a group of errors using the FileMultiError object.
setFinalTimeout() can be used to set the "final timeout". This timeout is used during close operations to wait until all pending read operations are finished. By default, this value is the triple times of the timeout.
ScanFile class is designed to scan a file. On HCore targets this class is based on OS native file input-output functions.
class ScanFile : public ScanBase
{
....
private:
virtual PtrLen<const char> underflow();
public:
// constructors
ScanFile() noexcept;
explicit ScanFile(StrLen file_name,bool disable_exceptions=false);
~ScanFile();
// methods
bool isOpened() const;
void open(StrLen file_name,bool disable_exceptions=false);
void disableExceptions();
void soft_close(FileMultiError &errout);
void close();
};
ScanFile object can be opened or closed. To scan from a particular file, the ScanFile object must be opened and the file name must be provided. It can be done using the constructor or the method open(). Default constructor creates an object in the closed state. Non-default opens a file. In case of error an exception is thrown.
Destructor closes an opened object. Errors are reported.
isOpened() returns true, if the file is opened, and false otherwise.
open() opens a closed object with the given file name. In case of error an exception is thrown.
close() closes an opened object. In case of error and if there is a pending read error an exception is thrown.
soft_close() does not throw, it returns instead a group of errors using the FileMultiError object.
disableExceptions() disables exceptions produced by the file reading operations. You may call this method after the open(). Or you may set the disable_exceptions argument to true for the method open(). This method does the initial read, so it may throw a "reading" exception. If exceptions are disabled, then the special internal error flag is set in case of reading error. This flag is added in the error list by the close operation.