|
|||
|
|||
|
#include <modules.h>
Inheritance diagram for FileReader:


Public Member Functions | |
| FileReader (InspIRCd *Instance) | |
| Default constructor. | |
| FileReader (InspIRCd *Instance, const std::string &filename) | |
| Secondary constructor. | |
| ~FileReader () | |
| Default destructor. | |
| void | LoadFile (const std::string &filename) |
| Used to load a file. | |
| std::string | Contents () |
| Returns the whole content of the file as std::string. | |
| unsigned long | ContentSize () |
| Returns the entire size of the file as std::string. | |
| bool | Exists () |
| Returns true if the file exists This function will return false if the file could not be opened. | |
| std::string | GetLine (int x) |
| Retrieve one line from the file. | |
| int | FileSize () |
| Returns the size of the file in lines. | |
Private Member Functions | |
| void | CalcSize () |
| Calculate content size in bytes. | |
Private Attributes | |
| InspIRCd * | ServerInstance |
| file_cache | fc |
| The file contents. | |
| unsigned long | contentsize |
| Content size in bytes. | |
This class contains methods for read-only manipulation of a text file in memory. Either use the constructor type with one parameter to load a file into memory at construction, or use the LoadFile method to load a file.
Definition at line 1534 of file modules.h.
|
|
Default constructor. This method does not load any file into memory, you must use the LoadFile method after constructing the class this way. Definition at line 931 of file modules.cpp. |
|
||||||||||||
|
Secondary constructor. This method initialises the class with a file loaded into it ready for GetLine and and other methods to be called. If the file could not be loaded, FileReader::FileSize returns 0. Definition at line 926 of file modules.cpp. References LoadFile(). |
|
|
Default destructor. This deletes the memory allocated to the file. Definition at line 971 of file modules.cpp. |
|
|
Calculate content size in bytes.
Definition at line 951 of file modules.cpp. References contentsize, and fc. Referenced by LoadFile(). |
|
|
Returns the whole content of the file as std::string.
Definition at line 935 of file modules.cpp. References fc. Referenced by HttpServerSocket::ServeData(). |
|
|
Returns the entire size of the file as std::string.
Definition at line 946 of file modules.cpp. References contentsize. Referenced by HttpServerSocket::ServeData(). |
|
|
Returns true if the file exists This function will return false if the file could not be opened.
Definition at line 975 of file modules.cpp. References fc. Referenced by CommandRandquote::Handle(), ModuleRandQuote::ModuleRandQuote(), and ModuleHttpServer::ReadConfig(). |
|
|
Returns the size of the file in lines. This method returns the number of lines in the read file. If it is 0, no lines have been read into memory, either because the file is empty or it does not exist, or cannot be opened due to permission problems. Definition at line 987 of file modules.cpp. References fc. Referenced by CommandRandquote::Handle(), and ShowOperMOTD(). |
|
|
Retrieve one line from the file. This method retrieves one line from the text file. If an empty non-NULL string is returned, the index was out of bounds, or the line had no data on it. Definition at line 980 of file modules.cpp. References fc. Referenced by CommandRandquote::Handle(), and ShowOperMOTD(). |
|
|
Used to load a file. This method loads a file into the class ready for GetLine and and other methods to be called. If the file could not be loaded, FileReader::FileSize returns 0. Definition at line 959 of file modules.cpp. References CalcSize(), InspIRCd::Config, fc, ServerConfig::ReadFile(), and ServerInstance. Referenced by FileReader(). |
|
|
Content size in bytes.
Definition at line 1543 of file modules.h. Referenced by CalcSize(), and ContentSize(). |
|
|
The file contents.
Definition at line 1539 of file modules.h. Referenced by CalcSize(), Contents(), Exists(), FileSize(), GetLine(), and LoadFile(). |
|
|
Definition at line 1536 of file modules.h. Referenced by LoadFile(). |