@@ -158,62 +158,6 @@ public function rollback()
158
158
$ this ->backups = array ();
159
159
}
160
160
161
- /**
162
- * Prepares source paths for backup.
163
- *
164
- * @param $paths
165
- *
166
- * @see PathPreserver::restorePathPermissions()
167
- */
168
- protected function preparePathPermissions ($ paths )
169
- {
170
- foreach ($ paths as $ path ) {
171
- // In the case the path or its parent is not writable, we cannot move the
172
- // path. Therefore we change the permissions temporarily and restore them
173
- // later.
174
- if (!is_writable ($ path )) {
175
- $ this ->makePathWritable ($ path );
176
- }
177
-
178
- $ parent = dirname ($ path );
179
- if (!is_writable ($ parent )) {
180
- $ this ->makePathWritable ($ parent );
181
- }
182
- }
183
- }
184
-
185
- /**
186
- * Helper to make path writable.
187
- *
188
- * @param string $path
189
- */
190
- protected function makePathWritable ($ path )
191
- {
192
- // Make parent writable, before we can change the path itself.
193
- $ parent = dirname ($ path );
194
- if ($ parent != '. ' && !is_writable ($ parent )) {
195
- $ this ->makePathWritable ($ parent );
196
- }
197
-
198
- $ this ->filepermissions [$ path ] = fileperms ($ path );
199
- chmod ($ path , static ::FILEPERM );
200
- }
201
-
202
- /**
203
- * Restores path permissions that have been changed before.
204
- *
205
- * @see PathPreserver::preparePathPermissions()
206
- */
207
- protected function restorePathPermissions ()
208
- {
209
- // We restore child permissions first.
210
- arsort ($ this ->filepermissions );
211
-
212
- foreach ($ this ->filepermissions as $ path => $ perm ) {
213
- chmod ($ path , $ perm );
214
- }
215
- }
216
-
217
161
/**
218
162
* Check if file really exists.
219
163
*
@@ -232,7 +176,7 @@ protected function restorePathPermissions()
232
176
public static function fileExists ($ path )
233
177
{
234
178
235
- // Get all parent directories.
179
+ // Get all parent directories.
236
180
$ folders = array ();
237
181
$ resetPerms = array ();
238
182
$ folder = $ path ;
@@ -269,4 +213,60 @@ public static function fileExists($path)
269
213
270
214
return $ return ;
271
215
}
216
+
217
+ /**
218
+ * Prepares source paths for backup.
219
+ *
220
+ * @param $paths
221
+ *
222
+ * @see PathPreserver::restorePathPermissions()
223
+ */
224
+ protected function preparePathPermissions ($ paths )
225
+ {
226
+ foreach ($ paths as $ path ) {
227
+ // In the case the path or its parent is not writable, we cannot move the
228
+ // path. Therefore we change the permissions temporarily and restore them
229
+ // later.
230
+ if (!is_writable ($ path )) {
231
+ $ this ->makePathWritable ($ path );
232
+ }
233
+
234
+ $ parent = dirname ($ path );
235
+ if (!is_writable ($ parent )) {
236
+ $ this ->makePathWritable ($ parent );
237
+ }
238
+ }
239
+ }
240
+
241
+ /**
242
+ * Helper to make path writable.
243
+ *
244
+ * @param string $path
245
+ */
246
+ protected function makePathWritable ($ path )
247
+ {
248
+ // Make parent writable, before we can change the path itself.
249
+ $ parent = dirname ($ path );
250
+ if ($ parent != '. ' && !is_writable ($ parent )) {
251
+ $ this ->makePathWritable ($ parent );
252
+ }
253
+
254
+ $ this ->filepermissions [$ path ] = fileperms ($ path );
255
+ chmod ($ path , static ::FILEPERM );
256
+ }
257
+
258
+ /**
259
+ * Restores path permissions that have been changed before.
260
+ *
261
+ * @see PathPreserver::preparePathPermissions()
262
+ */
263
+ protected function restorePathPermissions ()
264
+ {
265
+ // We restore child permissions first.
266
+ arsort ($ this ->filepermissions );
267
+
268
+ foreach ($ this ->filepermissions as $ path => $ perm ) {
269
+ chmod ($ path , $ perm );
270
+ }
271
+ }
272
272
}
0 commit comments