Copy a list of files, returning an array of failures.

@param  array $files
@return array
426180
protected function copy( $files ) {
		$failures = [];

		foreach ( $files as $source => $destination ) {
			if ( file_exists( $destination ) ) {
				$failures[ $source ] = $destination;
				continue;
			}

			$directory = dirname( $destination );
			if ( ! file_exists( $directory ) ) {
				mkdir( $directory );
			}

			copy( $source, $destination );
		}

		return $failures;
	}
1250536
public function setFiles($files = array())
    {
        if (count($files) === 0) {
            $this->_files = $_FILES;
        } else {
            $this->_files = $files;
        }
        return $this;
    }
129413
public function deleteFiles(array $files)
    {
        $count = 0;
        try {
            foreach ($files as $file) {
                $this->sevenZip->delEntry($file);
                $count++;
            }
            return $count;
        } catch (Exception $e) {
            throw new Exception('Could not modify archive: '.$e->getMessage(), $e->getCode(), $e);
        }
    }
5575
protected function extract(array $files)
    {
        foreach ($files as $key => $file) {
            if ($file instanceof Doozr_Request_File) {

                // Simple security layer
                $filename = $this->cleanFilename($file->getClientFilename());

                // @todo Move to a basic validation applied always for files if enabled in configuration.
                #$mediaType = $this->getMimeTypeByExtension(pathinfo($filename)['extension']);

                /* @var Doozr_Request_File $file */
                // Put everything in a simple array structure ...
                $files[$key] = [
                    'name'     => $filename,
                    'type'     => $file->getClientMediaType(),
                    'tmp_name' => $file->getTemporaryName(),
                    'error'    => $file->getError(),
                    'size'     => $file->getSize(),
                    'emulated' => false,
                ];
            } else {
                $files[$key] = $this->extract($file);
            }
        }

        return $files;
    }
1359152
public function createUploadedFileFromServer(array $files)
        {
            $normalized = [];
            foreach ($files as $key => $value) {
                
                if (!isset($value['error'])) {
                    if (is_array($value)) {
                        $normalized[$key] = $this->createUploadedFileFromServer($value);
                    }
                    continue;
                }
                
                $normalized[$key] = [];
                if (!is_array($value['error'])) {

                    if ($value['error'] === 4) {
                        $stream = (new StreamFactory)->createStream('');
                    } else {
                        $stream = (new StreamFactory)->createStreamFromFile($value['tmp_name'], 'r');    
                    }
                    
                    $normalized[$key] = $this->createUploadedFile(
                        $stream,
                        $value['size'],
                        $value['error'],
                        $value['name'],
                        $value['type']
                    );

                } else {

                    $sub = [];
                    foreach ($value['error'] as $id => $error) {
   
                        $sub[$id]['name']     = $value['name'][$id];
                        $sub[$id]['type']     = $value['type'][$id];
                        $sub[$id]['tmp_name'] = $value['tmp_name'][$id];
                        $sub[$id]['error']    = $value['error'][$id];
                        $sub[$id]['size']     = $value['size'][$id];
                        
                        $normalized[$key] = $this->createUploadedFileFromServer($sub);
                    
                    }

                }

            }
            return $normalized;
        }
606318
public function setFiles(array $files)
    {
        foreach($files as $file) {
            if (!$file instanceof File) {
                throw new ObjectNotAFileException($file . ' is not a file');
            }
        }

        $this->files = $files;
        return $this;
    }
1730
public static function createFromFilesGlobal(array $files) : array
    {
        $items = [];
        $files = self::normalizeSuperglobal($files);
        self::buildMap($files, $items);

        return $items;
    }
875144
public function handleMultipleFiles(array $files)
    {
        foreach ($files as $file) {
            $this->handleSingleFile($file);
        }
        return $this->getUploadedFilesList();
    }
123229
public function findRequiredFiles(array $files)
    {
        foreach ($files as $file) {
            if (file_exists($this->plugin->directory.'/'.$file)) {
                $this->addSuccess(sprintf('Found required file: %s', $file));
            } else {
                $this->addError(sprintf('Failed to find required file: %s', $file));
            }
        }
    }
145597
private function dealFiles($files)
    {
        $fileArray = [];
        $n = 0;
        foreach ($files as $key => $file) {
            if (is_array($file['name'])) {
                $keys = array_keys($file);
                $count = count($file['name']);
                for ($i = 0; $i < $count; $i++) {
                    $fileArray[$n]['key'] = $key;
                    foreach ($keys as $_key) {
                        $fileArray[$n][$_key] = $file[$_key][$i];
                    }
                    $n++;
                }
            } else {
                $fileArray = $files;
                break;
            }
        }

        return $fileArray;
    }
1179985
public function requireFiles(array $files)
    {
        $path = $this->getPath();
        foreach ($files as $file) {
            $this->laravel['files']->requireOnce($path . '/' . $file . '.php');
        }
    }
246514
protected function retrieveAllFiles(array $paths)
    {
        $files = [];

        foreach ($paths as $path) {
            $newFiles = [];

            try {
                $newFiles = $this->retrieveFiles($path);
            } catch (FileSystemException $e) {
                continue;
            } finally {
                $files = array_merge($files, $newFiles);
            }
        }

        return $files;
    }
311447
public static function multiple(
        array $files
    ) {
        $out = [];
        foreach ($files as $file) {
            $out[] = static::info($file);
        }

        return $out;
    }
1043746
public static function setFiles(array $files): array
    {
        $previousFiles = self::$files;
        self::$files = $files;

        foreach (self::$openedFiles as $file) {
            if ($file) {
                flock($file, LOCK_UN);
                fclose($file);
            }
        }
        self::$openedFiles = self::$lockedFiles = [];

        return $previousFiles;
    }
1152698
private static function normalizeSuperglobal(array $files) : array
    {
        $result = [];

        foreach ($files as $file) {
            $keys = array_keys($file);

            if (is_array($keys)) {
                foreach ($keys as $key) {
                    $result[$key] = [];
                    foreach ($files as $index => $file) {
                        $result[$key][$index] = $file[$key];
                    }
                }
            }

            // Only one of the entries was needed to get the PHP upload keys (name, tmp_name, etc.).
            break;
        }

        return $result;
    }
7079
public function delete(array $files)
    {
        $filesystem = $this->getFilesystem($this->field, $this->settings);
        $results = [];
        foreach ($files as $path) {
            $results[] = $this->deletePath($filesystem, $path);
        }

        return $results;
    }
1089630
private function removeBrokenFiles(array $files)
    {
        // Recursive logic to replace broken arrays with empty ones (which to be removed later)
        if (isset($files['error'])) {
            return $files['error'] == 4 ? array() : $files;
        }

        foreach ($files as $key => $value) {
            // Recursive call
            $files[$key] = call_user_func(array($this, __FUNCTION__), $value);
        }

        // Now remove empty arrays
        return array_filter($files);
    }