+ $tmpFiles[$src] = self::$RES_ERROR; // invalid path
+ continue;
+ }
+ // Create a new temporary file with the same extension...
+ $ext = FileBackend::extensionFromPath( $src );
+ $tmpFile = $this->tmpFileFactory->newTempFSFile( 'localcopy_', $ext );
+ if ( !$tmpFile ) {
+ $tmpFiles[$src] = self::$RES_ERROR;
+ continue;
+ }
+
+ $tmpPath = $tmpFile->getPath();
+ // Copy the source file over the temp file
+ $this->trapWarnings();
+ $isFile = is_file( $source ); // regular files only
+ $copySuccess = $isFile ? copy( $source, $tmpPath ) : false;
+ $hadError = $this->untrapWarnings();
+
+ if ( $copySuccess ) {
+ $this->chmod( $tmpPath );
+ $tmpFiles[$src] = $tmpFile;
+ } elseif ( $hadError ) {
+ $tmpFiles[$src] = self::$RES_ERROR; // copy failed