From 0131a3202597fe2cfefbb72e1a20fd266d48451a Mon Sep 17 00:00:00 2001
From: Robin Appelman <icewind@owncloud.com>
Date: Fri, 6 Sep 2013 20:38:59 +0200
Subject: [PATCH] extract interfaces from fileapi for public namespace

---
 lib/files/node/file.php          |   2 +-
 lib/files/node/folder.php        |   2 +-
 lib/files/node/node.php          |   2 +-
 lib/public/files/node/file.php   |  44 +++++++++++++
 lib/public/files/node/folder.php | 104 +++++++++++++++++++++++++++++
 lib/public/files/node/node.php   | 108 +++++++++++++++++++++++++++++++
 6 files changed, 259 insertions(+), 3 deletions(-)
 create mode 100644 lib/public/files/node/file.php
 create mode 100644 lib/public/files/node/folder.php
 create mode 100644 lib/public/files/node/node.php

diff --git a/lib/files/node/file.php b/lib/files/node/file.php
index 0ad5d68ec6..f13b474aa6 100644
--- a/lib/files/node/file.php
+++ b/lib/files/node/file.php
@@ -10,7 +10,7 @@ namespace OC\Files\Node;
 
 use OC\Files\NotPermittedException;
 
-class File extends Node {
+class File extends Node implements \OCP\Files\Node\File {
 	/**
 	 * @return string
 	 * @throws \OC\Files\NotPermittedException
diff --git a/lib/files/node/folder.php b/lib/files/node/folder.php
index f710ae5ae9..daf75d7c23 100644
--- a/lib/files/node/folder.php
+++ b/lib/files/node/folder.php
@@ -13,7 +13,7 @@ use OC\Files\Cache\Scanner;
 use OC\Files\NotFoundException;
 use OC\Files\NotPermittedException;
 
-class Folder extends Node {
+class Folder extends Node implements \OCP\Files\Node\Folder {
 	/**
 	 * @param string $path path relative to the folder
 	 * @return string
diff --git a/lib/files/node/node.php b/lib/files/node/node.php
index a1db042c25..5ee9f23161 100644
--- a/lib/files/node/node.php
+++ b/lib/files/node/node.php
@@ -15,7 +15,7 @@ use OC\Files\NotPermittedException;
 
 require_once 'files/exceptions.php';
 
-class Node {
+class Node implements \OCP\Files\Node\Node {
 	/**
 	 * @var \OC\Files\View $view
 	 */
diff --git a/lib/public/files/node/file.php b/lib/public/files/node/file.php
new file mode 100644
index 0000000000..193663f60b
--- /dev/null
+++ b/lib/public/files/node/file.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OCP\Files\Node;
+
+use OC\Files\NotPermittedException;
+
+interface File extends Node {
+	/**
+	 * @return string
+	 * @throws \OC\Files\NotPermittedException
+	 */
+	public function getContent();
+
+	/**
+	 * @param string $data
+	 * @throws \OC\Files\NotPermittedException
+	 */
+	public function putContent($data);
+
+	/**
+	 * @return string
+	 */
+	public function getMimeType();
+
+	/**
+	 * @param string $mode
+	 * @return resource
+	 * @throws \OC\Files\NotPermittedException
+	 */
+	public function fopen($mode);
+
+	/**
+	 * @param string $type
+	 * @param bool $raw
+	 * @return string
+	 */
+	public function hash($type, $raw = false);
+}
diff --git a/lib/public/files/node/folder.php b/lib/public/files/node/folder.php
new file mode 100644
index 0000000000..7b3ae80f0d
--- /dev/null
+++ b/lib/public/files/node/folder.php
@@ -0,0 +1,104 @@
+<?php
+/**
+ * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OCP\Files\Node;
+
+use OC\Files\Cache\Cache;
+use OC\Files\Cache\Scanner;
+use OC\Files\NotFoundException;
+use OC\Files\NotPermittedException;
+
+interface Folder extends Node {
+	/**
+	 * @param string $path path relative to the folder
+	 * @return string
+	 * @throws \OC\Files\NotPermittedException
+	 */
+	public function getFullPath($path);
+
+	/**
+	 * @param string $path
+	 * @throws \OC\Files\NotFoundException
+	 * @return string
+	 */
+	public function getRelativePath($path);
+
+	/**
+	 * check if a node is a (grand-)child of the folder
+	 *
+	 * @param \OC\Files\Node\Node $node
+	 * @return bool
+	 */
+	public function isSubNode($node);
+
+	/**
+	 * get the content of this directory
+	 *
+	 * @throws \OC\Files\NotFoundException
+	 * @return Node[]
+	 */
+	public function getDirectoryListing();
+
+	/**
+	 * Get the node at $path
+	 *
+	 * @param string $path
+	 * @return \OC\Files\Node\Node
+	 * @throws \OC\Files\NotFoundException
+	 */
+	public function get($path);
+
+	/**
+	 * @param string $path
+	 * @return bool
+	 */
+	public function nodeExists($path);
+
+	/**
+	 * @param string $path
+	 * @return Folder
+	 * @throws NotPermittedException
+	 */
+	public function newFolder($path);
+
+	/**
+	 * @param string $path
+	 * @return File
+	 * @throws NotPermittedException
+	 */
+	public function newFile($path);
+
+	/**
+	 * search for files with the name matching $query
+	 *
+	 * @param string $query
+	 * @return Node[]
+	 */
+	public function search($query);
+
+	/**
+	 * search for files by mimetype
+	 *
+	 * @param string $mimetype
+	 * @return Node[]
+	 */
+	public function searchByMime($mimetype);
+
+	/**
+	 * @param $id
+	 * @return Node[]
+	 */
+	public function getById($id);
+
+	public function getFreeSpace();
+
+	/**
+	 * @return bool
+	 */
+	public function isCreatable();
+}
diff --git a/lib/public/files/node/node.php b/lib/public/files/node/node.php
new file mode 100644
index 0000000000..085e880e37
--- /dev/null
+++ b/lib/public/files/node/node.php
@@ -0,0 +1,108 @@
+<?php
+/**
+ * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OCP\Files\Node;
+
+interface Node {
+	/**
+	 * @param string $targetPath
+	 * @throws \OC\Files\NotPermittedException
+	 * @return \OC\Files\Node\Node
+	 */
+	public function move($targetPath);
+
+	public function delete();
+
+	/**
+	 * @param string $targetPath
+	 * @return \OC\Files\Node\Node
+	 */
+	public function copy($targetPath);
+
+	/**
+	 * @param int $mtime
+	 * @throws \OC\Files\NotPermittedException
+	 */
+	public function touch($mtime = null);
+
+	/**
+	 * @return \OC\Files\Storage\Storage
+	 * @throws \OC\Files\NotFoundException
+	 */
+	public function getStorage();
+
+	/**
+	 * @return string
+	 */
+	public function getPath();
+
+	/**
+	 * @return string
+	 */
+	public function getInternalPath();
+
+	/**
+	 * @return int
+	 */
+	public function getId();
+
+	/**
+	 * @return array
+	 */
+	public function stat();
+
+	/**
+	 * @return int
+	 */
+	public function getMTime();
+
+	/**
+	 * @return int
+	 */
+	public function getSize();
+
+	/**
+	 * @return string
+	 */
+	public function getEtag();
+
+	/**
+	 * @return int
+	 */
+	public function getPermissions();
+
+	/**
+	 * @return bool
+	 */
+	public function isReadable();
+
+	/**
+	 * @return bool
+	 */
+	public function isUpdateable();
+
+	/**
+	 * @return bool
+	 */
+	public function isDeletable();
+
+	/**
+	 * @return bool
+	 */
+	public function isShareable();
+
+	/**
+	 * @return Node
+	 */
+	public function getParent();
+
+	/**
+	 * @return string
+	 */
+	public function getName();
+}
-- 
GitLab