Completed
Push — master ( 8ccb99...229289 )
by Morris
20:27
created
lib/private/Files/SimpleFS/SimpleFile.php 1 patch
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -29,144 +29,144 @@
 block discarded – undo
29 29
 
30 30
 class SimpleFile implements ISimpleFile  {
31 31
 
32
-	/** @var File $file */
33
-	private $file;
34
-
35
-	/**
36
-	 * File constructor.
37
-	 *
38
-	 * @param File $file
39
-	 */
40
-	public function __construct(File $file) {
41
-		$this->file = $file;
42
-	}
43
-
44
-	/**
45
-	 * Get the name
46
-	 *
47
-	 * @return string
48
-	 */
49
-	public function getName() {
50
-		return $this->file->getName();
51
-	}
52
-
53
-	/**
54
-	 * Get the size in bytes
55
-	 *
56
-	 * @return int
57
-	 */
58
-	public function getSize() {
59
-		return $this->file->getSize();
60
-	}
61
-
62
-	/**
63
-	 * Get the ETag
64
-	 *
65
-	 * @return string
66
-	 */
67
-	public function getETag() {
68
-		return $this->file->getEtag();
69
-	}
70
-
71
-	/**
72
-	 * Get the last modification time
73
-	 *
74
-	 * @return int
75
-	 */
76
-	public function getMTime() {
77
-		return $this->file->getMTime();
78
-	}
79
-
80
-	/**
81
-	 * Get the content
82
-	 *
83
-	 * @throws NotPermittedException
84
-	 * @throws NotFoundException
85
-	 * @return string
86
-	 */
87
-	public function getContent() {
88
-		$result = $this->file->getContent();
89
-
90
-		if ($result === false) {
91
-			$this->checkFile();
92
-		}
93
-
94
-		return $result;
95
-	}
96
-
97
-	/**
98
-	 * Overwrite the file
99
-	 *
100
-	 * @param string|resource $data
101
-	 * @throws NotPermittedException
102
-	 */
103
-	public function putContent($data) {
104
-		$this->file->putContent($data);
105
-	}
106
-
107
-	/**
108
-	 * Sometimes there are some issues with the AppData. Most of them are from
109
-	 * user error. But we should handle them gracefull anyway.
110
-	 *
111
-	 * If for some reason the current file can't be found. We remove it.
112
-	 * Then traverse up and check all folders if they exists. This so that the
113
-	 * next request will have a valid appdata structure again.
114
-	 *
115
-	 * @throws NotFoundException
116
-	 */
117
-	private function checkFile() {
118
-		$cur = $this->file;
119
-
120
-		while ($cur->stat() === false) {
121
-			$parent = $cur->getParent();
122
-			$cur->delete();
123
-			$cur = $parent;
124
-		}
125
-
126
-		if ($cur !== $this->file) {
127
-			throw new NotFoundException('File does not exist');
128
-		}
129
-	}
130
-
131
-
132
-	/**
133
-	 * Delete the file
134
-	 *
135
-	 * @throws NotPermittedException
136
-	 */
137
-	public function delete() {
138
-		$this->file->delete();
139
-	}
140
-
141
-	/**
142
-	 * Get the MimeType
143
-	 *
144
-	 * @return string
145
-	 */
146
-	public function getMimeType() {
147
-		return $this->file->getMimeType();
148
-	}
149
-
150
-	/**
151
-	 * Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen
152
-	 *
153
-	 * @return resource
154
-	 * @throws \OCP\Files\NotPermittedException
155
-	 * @since 14.0.0
156
-	 */
157
-	public function read() {
158
-		return $this->file->fopen('r');
159
-	}
160
-
161
-	/**
162
-	 * Open the file as stream for writing, resulting resource can be operated as stream like the result from php's own fopen
163
-	 *
164
-	 * @return resource
165
-	 * @throws \OCP\Files\NotPermittedException
166
-	 * @since 14.0.0
167
-	 */
168
-	public function write() {
169
-		return $this->file->fopen('w');
170
-	}
32
+    /** @var File $file */
33
+    private $file;
34
+
35
+    /**
36
+     * File constructor.
37
+     *
38
+     * @param File $file
39
+     */
40
+    public function __construct(File $file) {
41
+        $this->file = $file;
42
+    }
43
+
44
+    /**
45
+     * Get the name
46
+     *
47
+     * @return string
48
+     */
49
+    public function getName() {
50
+        return $this->file->getName();
51
+    }
52
+
53
+    /**
54
+     * Get the size in bytes
55
+     *
56
+     * @return int
57
+     */
58
+    public function getSize() {
59
+        return $this->file->getSize();
60
+    }
61
+
62
+    /**
63
+     * Get the ETag
64
+     *
65
+     * @return string
66
+     */
67
+    public function getETag() {
68
+        return $this->file->getEtag();
69
+    }
70
+
71
+    /**
72
+     * Get the last modification time
73
+     *
74
+     * @return int
75
+     */
76
+    public function getMTime() {
77
+        return $this->file->getMTime();
78
+    }
79
+
80
+    /**
81
+     * Get the content
82
+     *
83
+     * @throws NotPermittedException
84
+     * @throws NotFoundException
85
+     * @return string
86
+     */
87
+    public function getContent() {
88
+        $result = $this->file->getContent();
89
+
90
+        if ($result === false) {
91
+            $this->checkFile();
92
+        }
93
+
94
+        return $result;
95
+    }
96
+
97
+    /**
98
+     * Overwrite the file
99
+     *
100
+     * @param string|resource $data
101
+     * @throws NotPermittedException
102
+     */
103
+    public function putContent($data) {
104
+        $this->file->putContent($data);
105
+    }
106
+
107
+    /**
108
+     * Sometimes there are some issues with the AppData. Most of them are from
109
+     * user error. But we should handle them gracefull anyway.
110
+     *
111
+     * If for some reason the current file can't be found. We remove it.
112
+     * Then traverse up and check all folders if they exists. This so that the
113
+     * next request will have a valid appdata structure again.
114
+     *
115
+     * @throws NotFoundException
116
+     */
117
+    private function checkFile() {
118
+        $cur = $this->file;
119
+
120
+        while ($cur->stat() === false) {
121
+            $parent = $cur->getParent();
122
+            $cur->delete();
123
+            $cur = $parent;
124
+        }
125
+
126
+        if ($cur !== $this->file) {
127
+            throw new NotFoundException('File does not exist');
128
+        }
129
+    }
130
+
131
+
132
+    /**
133
+     * Delete the file
134
+     *
135
+     * @throws NotPermittedException
136
+     */
137
+    public function delete() {
138
+        $this->file->delete();
139
+    }
140
+
141
+    /**
142
+     * Get the MimeType
143
+     *
144
+     * @return string
145
+     */
146
+    public function getMimeType() {
147
+        return $this->file->getMimeType();
148
+    }
149
+
150
+    /**
151
+     * Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen
152
+     *
153
+     * @return resource
154
+     * @throws \OCP\Files\NotPermittedException
155
+     * @since 14.0.0
156
+     */
157
+    public function read() {
158
+        return $this->file->fopen('r');
159
+    }
160
+
161
+    /**
162
+     * Open the file as stream for writing, resulting resource can be operated as stream like the result from php's own fopen
163
+     *
164
+     * @return resource
165
+     * @throws \OCP\Files\NotPermittedException
166
+     * @since 14.0.0
167
+     */
168
+    public function write() {
169
+        return $this->file->fopen('w');
170
+    }
171 171
 
172 172
 }
Please login to merge, or discard this patch.
lib/public/Files/SimpleFS/ISimpleFile.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -33,88 +33,88 @@
 block discarded – undo
33 33
  */
34 34
 interface ISimpleFile {
35 35
 
36
-	/**
37
-	 * Get the name
38
-	 *
39
-	 * @return string
40
-	 * @since 11.0.0
41
-	 */
42
-	public function getName();
36
+    /**
37
+     * Get the name
38
+     *
39
+     * @return string
40
+     * @since 11.0.0
41
+     */
42
+    public function getName();
43 43
 
44
-	/**
45
-	 * Get the size in bytes
46
-	 *
47
-	 * @return int
48
-	 * @since 11.0.0
49
-	 */
50
-	public function getSize();
44
+    /**
45
+     * Get the size in bytes
46
+     *
47
+     * @return int
48
+     * @since 11.0.0
49
+     */
50
+    public function getSize();
51 51
 
52
-	/**
53
-	 * Get the ETag
54
-	 *
55
-	 * @return string
56
-	 * @since 11.0.0
57
-	 */
58
-	public function getETag();
52
+    /**
53
+     * Get the ETag
54
+     *
55
+     * @return string
56
+     * @since 11.0.0
57
+     */
58
+    public function getETag();
59 59
 
60
-	/**
61
-	 * Get the last modification time
62
-	 *
63
-	 * @return int
64
-	 * @since 11.0.0
65
-	 */
66
-	public function getMTime();
60
+    /**
61
+     * Get the last modification time
62
+     *
63
+     * @return int
64
+     * @since 11.0.0
65
+     */
66
+    public function getMTime();
67 67
 
68
-	/**
69
-	 * Get the content
70
-	 *
71
-	 * @throws NotPermittedException
72
-	 * @throws NotFoundException
73
-	 * @return string
74
-	 * @since 11.0.0
75
-	 */
76
-	public function getContent();
68
+    /**
69
+     * Get the content
70
+     *
71
+     * @throws NotPermittedException
72
+     * @throws NotFoundException
73
+     * @return string
74
+     * @since 11.0.0
75
+     */
76
+    public function getContent();
77 77
 
78
-	/**
79
-	 * Overwrite the file
80
-	 *
81
-	 * @param string|resource $data
82
-	 * @throws NotPermittedException
83
-	 * @since 11.0.0
84
-	 */
85
-	public function putContent($data);
78
+    /**
79
+     * Overwrite the file
80
+     *
81
+     * @param string|resource $data
82
+     * @throws NotPermittedException
83
+     * @since 11.0.0
84
+     */
85
+    public function putContent($data);
86 86
 
87
-	/**
88
-	 * Delete the file
89
-	 *
90
-	 * @throws NotPermittedException
91
-	 * @since 11.0.0
92
-	 */
93
-	public function delete();
87
+    /**
88
+     * Delete the file
89
+     *
90
+     * @throws NotPermittedException
91
+     * @since 11.0.0
92
+     */
93
+    public function delete();
94 94
 
95
-	/**
96
-	 * Get the MimeType
97
-	 *
98
-	 * @return string
99
-	 * @since 11.0.0
100
-	 */
101
-	public function getMimeType();
95
+    /**
96
+     * Get the MimeType
97
+     *
98
+     * @return string
99
+     * @since 11.0.0
100
+     */
101
+    public function getMimeType();
102 102
 
103
-	/**
104
-	 * Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen
105
-	 *
106
-	 * @return resource
107
-	 * @throws \OCP\Files\NotPermittedException
108
-	 * @since 14.0.0
109
-	 */
110
-	public function read();
103
+    /**
104
+     * Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen
105
+     *
106
+     * @return resource
107
+     * @throws \OCP\Files\NotPermittedException
108
+     * @since 14.0.0
109
+     */
110
+    public function read();
111 111
 
112
-	/**
113
-	 * Open the file as stream for writing, resulting resource can be operated as stream like the result from php's own fopen
114
-	 *
115
-	 * @return resource
116
-	 * @throws \OCP\Files\NotPermittedException
117
-	 * @since 14.0.0
118
-	 */
119
-	public function write();
112
+    /**
113
+     * Open the file as stream for writing, resulting resource can be operated as stream like the result from php's own fopen
114
+     *
115
+     * @return resource
116
+     * @throws \OCP\Files\NotPermittedException
117
+     * @since 14.0.0
118
+     */
119
+    public function write();
120 120
 }
Please login to merge, or discard this patch.