public function putContent($data) {
try {
if ($this->file) {
- return $this->file->putContent($data);
+ $this->file->putContent($data);
} else {
$this->file = $this->parentFolder->newFile($this->name, $data);
}
return new SimpleFile($file);
}
- public function newFile($name) {
- // delay creating the file until it's written to
- return new NewSimpleFile($this->folder, $name);
+ public function newFile($name, $content = null) {
+ if ($content === null) {
+ // delay creating the file until it's written to
+ return new NewSimpleFile($this->folder, $name);
+ } else {
+ $file = $this->folder->newFile($name, $content);
+ return new SimpleFile($file);
+ }
}
}
* Create a new file
*
* @param string $path relative path of the new file
- * @param string | resource | null $content content for the new file, since 19.0.0
+ * @param string|resource|null $content content for the new file, since 19.0.0
* @return \OCP\Files\File
* @throws \OCP\Files\NotPermittedException
* @since 6.0.0
* Creates a new file with $name in the folder
*
* @param string $name
+ * @param string|resource|null $content @since 19.0.0
* @return ISimpleFile
* @throws NotPermittedException
* @since 11.0.0
*/
- public function newFile($name);
+ public function newFile($name, $content = null);
/**
* Remove the folder and all the files in it