diff --git a/classes/logstream.class.php b/classes/logstream.class.php index 395d3f9..527eb1b 100644 --- a/classes/logstream.class.php +++ b/classes/logstream.class.php @@ -137,6 +137,18 @@ abstract class LogStream { * @return integer Error state */ public abstract function Sseek(&$uID, $mode, $numrecs); + + + /** + * If you are interested in how many messages are in the stream, call this method. + * But be aware of that some stream can not provide a message count. This is probably + * because of performance reason or any other. However, if GetMessageCount return -1 + * this does not mean that there is no message in the stream, it is just not countable. + * If there is no message 0 will be returned. + * + * @return integer Amount of messages within the stream. -1 means that no count is available. + */ + public abstract function GetMessageCount(); } diff --git a/classes/logstreamdisk.class.php b/classes/logstreamdisk.class.php index b9a931c..e79ed14 100644 --- a/classes/logstreamdisk.class.php +++ b/classes/logstreamdisk.class.php @@ -378,6 +378,17 @@ class LogStreamDisk extends LogStream { return SUCCESS; } + /** + * GetMessageCount will always return -1 which means + * that the message count is not available. We refuse + * the request of the message count due to a count would + * require to read the whole file which would be a big + * pain if the file is e.g. 1 gb. + */ + public function GetMessageCount() { + return -1; + } + /** * Set the direction the stream should read data. *