Code Duplication    Length = 14-15 lines in 4 locations

apps/files_external/lib/Lib/Storage/Dropbox.php 1 location

@@ 301-314 (lines=14) @@
298
			case 'x':
299
			case 'x+':
300
			case 'c':
301
			case 'c+':
302
				if (strrpos($path, '.') !== false) {
303
					$ext = substr($path, strrpos($path, '.'));
304
				} else {
305
					$ext = '';
306
				}
307
				$tmpFile = \OCP\Files::tmpFile($ext);
308
				\OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
309
				if ($this->file_exists($path)) {
310
					$source = $this->fopen($path, 'r');
311
					file_put_contents($tmpFile, $source);
312
				}
313
				self::$tempFiles[$tmpFile] = $path;
314
				return fopen('close://'.$tmpFile, $mode);
315
		}
316
		return false;
317
	}

apps/files_external/lib/Lib/Storage/FTP.php 1 location

@@ 122-135 (lines=14) @@
119
			case 'x':
120
			case 'x+':
121
			case 'c':
122
			case 'c+':
123
				//emulate these
124
				if (strrpos($path, '.')!==false) {
125
					$ext=substr($path, strrpos($path, '.'));
126
				} else {
127
					$ext='';
128
				}
129
				$tmpFile=\OCP\Files::tmpFile($ext);
130
				\OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
131
				if ($this->file_exists($path)) {
132
					$this->getFile($path, $tmpFile);
133
				}
134
				self::$tempFiles[$tmpFile]=$path;
135
				return fopen('close://'.$tmpFile, $mode);
136
		}
137
		return false;
138
	}

apps/files_external/lib/Lib/Storage/AmazonS3.php 1 location

@@ 362-376 (lines=15) @@
359
			case 'x':
360
			case 'x+':
361
			case 'c':
362
			case 'c+':
363
				if (strrpos($path, '.') !== false) {
364
					$ext = substr($path, strrpos($path, '.'));
365
				} else {
366
					$ext = '';
367
				}
368
				$tmpFile = \OCP\Files::tmpFile($ext);
369
				\OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
370
				if ($this->file_exists($path)) {
371
					$source = $this->fopen($path, 'r');
372
					file_put_contents($tmpFile, $source);
373
				}
374
				self::$tmpFiles[$tmpFile] = $path;
375
376
				return fopen('close://' . $tmpFile, $mode);
377
		}
378
		return false;
379
	}

lib/private/Files/ObjectStore/ObjectStoreStorage.php 1 location

@@ 287-301 (lines=15) @@
284
			case 'x':
285
			case 'x+':
286
			case 'c':
287
			case 'c+':
288
				if (strrpos($path, '.') !== false) {
289
					$ext = substr($path, strrpos($path, '.'));
290
				} else {
291
					$ext = '';
292
				}
293
				$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
294
				\OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
295
				if ($this->file_exists($path)) {
296
					$source = $this->fopen($path, 'r');
297
					file_put_contents($tmpFile, $source);
298
				}
299
				self::$tmpFiles[$tmpFile] = $path;
300
301
				return fopen('close://' . $tmpFile, $mode);
302
		}
303
		return false;
304
	}