/** * {@inheritDoc} */ public function open(StreamMode $mode) { $this->mode = $mode; $exists = $this->adapter->exists($this->key); if ($exists && !$mode->allowsExistingFileOpening() || !$exists && !$mode->allowsNewFileOpening()) { return false; } if ($mode->impliesExistingContentDeletion()) { $this->adapter->write($this->key, ''); $this->content = ''; } else { $this->content = $this->adapter->read($this->key); } $this->numBytes = Util\Size::fromContent($this->content); $this->position = $mode->impliesPositioningCursorAtTheEnd() ? $this->numBytes : 0; $this->synchronized = true; return true; }