public final function getFileName () {
return $this->fileName;
}
+
+ /**
+ * "Getter" for seek position
+ *
+ * @return $seekPosition Current seek position
+ */
+ public final function getPosition () {
+ return ftell($this->getPointer());
+ }
+
+ /**
+ * Seek to given offset (default) or other possibilities as fseek() gives.
+ *
+ * @param $offset Offset to seek to (or used as "base" for other seeks)
+ * @param $whence Added to offset (default: only use offset to seek to)
+ * @return $status Status of file seek: 0 = success, -1 = failed
+ */
+ public function seek ($offset, $whence = SEEK_SET) {
+ // Seek to position
+ $status = fseek($this->getPointer(), $offset, $whence);
+
+ // Return status
+ return $status;
+ }
+
+ /**
+ * Size of this file
+ *
+ * @return $size Size (in bytes) of file
+ */
+ public function size () {
+ // Get current seek position
+ $seekPosition = $this->getPosition();
+
+ // Seek to end
+ $this->seek(0, SEEK_END);
+
+ // Get position again (which is the end of the file)
+ $size = $this->getPosition();
+
+ // Reset seek position to old
+ $this->seek($seekPosition);
+
+ // Return size
+ return $size;
+ }
}
// [EOF]