From d11f01fa0f2228bb36e7b1a46cd80cec8bf1baac Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 24 Mar 2015 15:00:36 +0100 Subject: Add `getNonExistingName()` to the node api --- lib/private/files/node/folder.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/private/files/node') diff --git a/lib/private/files/node/folder.php b/lib/private/files/node/folder.php index 5fd73cc5d36..18a93913f06 100644 --- a/lib/private/files/node/folder.php +++ b/lib/private/files/node/folder.php @@ -389,4 +389,16 @@ class Folder extends Node implements \OCP\Files\Folder { throw new NotPermittedException(); } } + + /** + * Add a suffix to the name in case the file exists + * + * @param string $name + * @return string + * @throws NotPermittedException + */ + public function getNonExistingName($name) { + $uniqueName = \OC_Helper::buildNotExistingFileNameForView($this->getPath(), $name, $this->view); + return trim($this->getRelativePath($uniqueName), '/'); + } } -- cgit v1.2.3