diff options
Diffstat (limited to 'lib/private/Files/Node')
-rw-r--r-- | lib/private/Files/Node/Folder.php | 10 | ||||
-rw-r--r-- | lib/private/Files/Node/LazyRoot.php | 2 | ||||
-rw-r--r-- | lib/private/Files/Node/NonExistingFolder.php | 2 |
3 files changed, 10 insertions, 4 deletions
diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php index 1267c818668..727b08e9335 100644 --- a/lib/private/Files/Node/Folder.php +++ b/lib/private/Files/Node/Folder.php @@ -173,15 +173,21 @@ class Folder extends Node implements \OCP\Files\Folder { /** * @param string $path + * @param string | resource | null $content * @return \OC\Files\Node\File * @throws \OCP\Files\NotPermittedException */ - public function newFile($path) { + public function newFile($path, $content = null) { if ($this->checkPermissions(\OCP\Constants::PERMISSION_CREATE)) { $fullPath = $this->getFullPath($path); $nonExisting = new NonExistingFile($this->root, $this->view, $fullPath); $this->sendHooks(['preWrite', 'preCreate'], [$nonExisting]); - if (!$this->view->touch($fullPath)) { + if ($content !== null) { + $result = $this->view->file_put_contents($fullPath, $content); + } else { + $result = $this->view->touch($fullPath); + } + if (!$result) { throw new NotPermittedException('Could not create path'); } $node = new File($this->root, $this->view, $fullPath); diff --git a/lib/private/Files/Node/LazyRoot.php b/lib/private/Files/Node/LazyRoot.php index 76868cfa5cd..8076c3b4f6a 100644 --- a/lib/private/Files/Node/LazyRoot.php +++ b/lib/private/Files/Node/LazyRoot.php @@ -394,7 +394,7 @@ class LazyRoot implements IRootFolder { /** * @inheritDoc */ - public function newFile($path) { + public function newFile($path, $content = null) { return $this->__call(__FUNCTION__, func_get_args()); } diff --git a/lib/private/Files/Node/NonExistingFolder.php b/lib/private/Files/Node/NonExistingFolder.php index 30470740495..65af837da43 100644 --- a/lib/private/Files/Node/NonExistingFolder.php +++ b/lib/private/Files/Node/NonExistingFolder.php @@ -139,7 +139,7 @@ class NonExistingFolder extends Folder { throw new NotFoundException(); } - public function newFile($path) { + public function newFile($path, $content = null) { throw new NotFoundException(); } |