}
// Try to open a handler
- $filePointer = fopen($fileName, 'a+b');
+ $filePointer = fopen($fileName, 'c+b');
if ((is_null($filePointer)) || ($filePointer === FALSE)) {
// Something bad happend
throw new FileIoException($fileName, self::EXCEPTION_FILE_POINTER_INVALID);
}
// Write data to the file pointer and return written bytes
- return fwrite($this->getPointer(), $dataStream);
+ return fwrite($this->getPointer(), $dataStream, strlen($dataStream));
+ }
+
+ /**
+ * Rewinds to the beginning of the file
+ *
+ * @return $status Status of this operation
+ */
+ public function rewind () {
+ // Rewind the pointer
+ return rewind($this->getPointer());
+ }
+
+ /**
+ * Seeks to given position
+ *
+ * @param $seekPosition Seek position in file
+ * @param $whence "Seek mode" (see http://de.php.net/fseek)
+ * @return $status Status of this operation
+ */
+ public function seek ($seekPosition, $whence = SEEK_SET) {
+ // Move the file pointer
+ return fseek($this->getPointer(), $seekPosition, $whence);
}
}