Función para mover ficheros

@access  public
@param   $path
@param   $target
@param   $fileName
@param   bool    $encryption
@param   bool    $newFilename
@return  bool
165143
public static function move($path, $target, $fileName, $encryption = false, $newFilename = false)
    {
        $fileNameOld    = $fileName;
        $extension      = File::extension($fileName);
        $baseName       = basename($fileName, '.' . $extension);

        if ($encryption)
        {
            mt_srand();
            $fileName = md5(uniqid(mt_rand())) . "." . $extension;
        }
        elseif ($newFilename)
        {
            $fileName = $newFilename . "." . $extension;
        }

        $i = 0;
        while (File::exists($target . '/' . $fileName))
        {
            $i++;
            $fileName = $baseName . '-' . $i . '.' . $extension;
        }
        
        File::move($path . '/' . $fileNameOld, $target . '/' . $fileName);

        return $fileName;
    }
1007027
protected function extractTarFile($filename, $target)
    {
        $fileHandler = fopen($filename, 'r');
        $hardlinks = [];

        while (false === $this->isEof($fileHandler)) {
            $fields = $this->readBlockHeader($fileHandler, $filename);

            // deal with empty blocks in sparse files
            if (true === $fields['is_empty']) {
                continue;
            }

            if (false === $fields['is_valid_checksum']) {
                throw new Exception\IO\Input\FileCorruptedException($filename);
            }

            $name = $fields['name'];
            $type = $fields['type'];

            $location = $target . DIRECTORY_SEPARATOR . $name;
            switch ($type) {
                case self::TYPE_FILE:
                    $this->doExtractFile($location, $fields, $fileHandler);
                    break;
                case self::TYPE_DIRECTORY:
                    $this->doExtractDir($location);
                    break;
                case self::TYPE_HARD_LINK:
                    $hardlinks[$location] = $fields;
                    break;
                case self::TYPE_SYMBOLIC_LINK:
                    $this->doExtractSymLink($location, $fields);
                    break;
            }
        }

        // This should be done after extract all the files
        foreach ($hardlinks as $location => $fields) {
            $this->doExtractHardLink($location, $fields, $target);
        }

        fclose($fileHandler);

        return true;
    }
1323335
public function DecryptFile($path, $key)
	{
		if (!file_exists($path))
		{
			throw new GrabzItException("File: " . $path . " does not exist", GrabzItException::FILE_NON_EXISTANT_PATH);
		}
		$data = file_get_contents($path);
		file_put_contents($path, $this->Decrypt($data, $key));
		return true;
	}
578870
public static function find($fileName = false, $path = false) {

        if($fileName) {

            if(!$path) {

                $path = __DIR__;
            }

            if(self::isFolder($path)) {

                $dir = new \RecursiveDirectoryIterator($path);
                foreach (new \RecursiveIteratorIterator($dir) as $filePath) {
                    
                    if($fileName == basename($filePath)) {

                        return $filePath;
                    }
                }
            }
        }

        return false;
    }
14496
public function copy($path, $newpath)
    {
        $source = $this->getSourcePath($path);

        return (bool) $this->client->copy($this->getBucket(), $newpath, $source);
    }
7118
public function rename($bucketName, $bucketId, $fileName, $targetBucketId, $newFileName, $private = false)
    {
        $data = $this->get($bucketName, $fileName, $private, false);
        if (is_array($data) && array_key_exists('x-bz-file-id', $data['headers'])) {
            $result = $this->insert($targetBucketId, $data['content'], $newFileName);
            if ($result === false) {
                return false;
            }
            $response = $this->client->b2DeleteFileVersion($this->apiURL, $this->token, $data['headers']['x-bz-file-id'], $fileName);

            return $response->isOk();
        }

        return false;
    }
662096
public function copy($newpath)
    {
        if ($this->filesystem->copy($this->path, $newpath)) {
            return new File($this->filesystem, $newpath);
        }

        return false;
    }
802938
function getFile($slot_name, $target, $exts = NULL, $generate_names = false)
    {
        if(!$target) {
            throw new \Exception("Can't move file without destination.");
        }

        if(!array_key_exists($slot_name, $_FILES)) {
            return false;
        }

        $return = false;

        // Several files uploaded with the same name like uploads[].
        if(is_array($_FILES[$slot_name]['name'])) {
            if(!is_dir($target)) {
                throw new Exception("Target `$target' must be a directory for several files.");
            }

            $return = array();
            for($file_num = 0; $file_num < count($_FILES[$slot_name]['name']); $file_num++) {
                $file = array(
                    'name' => $_FILES[$slot_name]['name'][$file_num],
                    'type' => $_FILES[$slot_name]['type'][$file_num],
                    'tmp_name' => $_FILES[$slot_name]['tmp_name'][$file_num],
                    'error' => $_FILES[$slot_name]['error'][$file_num],
                    'size' => $_FILES[$slot_name]['size'][$file_num]
                    );

                $looptarget = '';
                if($generate_names) {
                    // Getting the ext. I don't use pathinfo() because the file may not exist...
                    $ext = substr(strrchr($file['name'], '.'), 0);
                    $looptarget = Utils::uniqueFilename($target, '', $ext);
                } else {
                    $looptarget = Utils::joinPaths($target, basename($file['name']));
                }

                try {
                    $return[] = $this->_getAndMoveFile($file, $looptarget, $exts);
                }
                catch(FileUploadError $e) {
                    $return[] = $e;
                }
            }
        } else {
            if(is_dir($target)) {
                if($generate_names) {
                    $ext = substr(strrchr($_FILES[$slot_name]['name'], '.'), 0);
                    $target = Utils::uniqueFilename($target, '', $ext);
                } else {
                    $target = Utils::joinPaths($target, basename($_FILES[$slot_name]['name']));
                }
            }

            try {
                $return = $this->_getAndMoveFile($_FILES[$slot_name], $target, $exts);
            }
            catch(FileUploadError $e)
            {
                return $e;
            }
        }

        return $return;
    }
881872
public function moveToPathWithRandomFileName(string $path, int $fileNameLength = 16)
    {
        return $this->process(FileMoverProcessor::withRandomFileName($this->movedClassName(), $path, $fileNameLength));
    }
1298487
public function copy( $path, $to )
    {
        if ( null === $this->identity )
        {
            return false;
        }

        if ( is_array( $path ) || is_object( $path ) ||
             is_array( $to )   || is_object( $to ) )
        {
            if ( ( ! is_array( $path ) && ! is_object( $path ) ) ||
                 ( ! is_array( $to )   && ! is_object( $to ) ) )
            {
                return false;
            }

            $result = array();

            foreach ( $path as $key => $p )
            {
                foreach ( $to as $toKey => $t )
                {
                    if ( $key == $toKey )
                    {
                        $result[$key] = $this->copy( $p, $t );
                    }
                }
            }

            return $result;
        }

        $to     = $this->validPath( $this->realPath( $to ) );
        $path   = $this->realPath( $path );
        $base   = $this->baseUrl . ( empty( $path ) ? '' : '/' . $path );
        $full   = realpath( $this->baseDir . '/' . $base );
        $isFile = is_file( $full );
        $isDir  = is_dir( $full );

        if ( $isFile )
        {
            $to = $this->secureFile( $to );
        }

        $toBase = $this->baseUrl . '/' . $to;
        $toFull = $this->baseDir . '/' . $toBase;

        if ( ! empty( $to ) && ! is_dir( dirname( $toFull ) ) )
        {
            $ba = '/' . basename( $to );
            $to = $this->createDir( dirname( $to ) );

            if ( ! $to )
            {
                return false;
            }

            $to     = $to . $ba;
            $toBase = $this->baseUrl . '/' . $to;
            $toFull = $this->baseDir . '/' . $toBase;
        }

        if ( ( $isFile || $isDir ) && is_dir( dirname( $toFull ) ) )
        {
            if ( $this->rights( $path )->read &&
                 $this->rights( $to )->write )
            {
                switch ( true )
                {
                    case $isDir:
                        $result = $this->_copy( $full, $toFull );
                        break;

                    case $isFile:
                        $result = @ copy( $full, $toFull );
                        break;
                }

                if ( $result )
                {
                    return $to;
                }
            }
        }

        return false;
    }
731378
public function copy($filename, $newFilePath, $newFileName = null, $pathToFile = null)
    {
        if ($pathToFile==null) {
            $pathToFile=$this->_filePath;
        }
        if ($newFileName==null) {
            $newFileName=$filename;
        }
        if (file_exists($pathToFile."/".$filename)) {
            return copy($pathToFile."/".$filename, $newFilePath."/".$newFileName);
        } else {
            return false;
        }
    }
665856
public static function put($path, $contents, $lock = false)
    {
        return file_put_contents($path, $contents, $lock ? LOCK_EX : 0);
    }
912902
protected function renameFile($path, $newName)
    {
        $newPath = pathinfo($path, PATHINFO_DIRNAME) . '/' . $newName;

        try {
            $success = rename($path, $newPath);

            // @codeCoverageIgnoreStart
        } catch (\Exception $e) {
            throw new CouldNotRetrieveRemoteFileException("Failed to rename '{$path}' to '{$newName}'", $e->getCode(), $e);
            // @codeCoverageIgnoreEnd
        }

        // @codeCoverageIgnoreStart
        if ( ! $success) {
            throw new CouldNotRetrieveRemoteFileException("Failed to rename '{$path}' to '{$newName}'");
        }
        // @codeCoverageIgnoreEnd

        return $newPath;
    }
1007144
public function move($new_path)
	{
		$info = pathinfo($this->path);

		$new_path = $this->area->get_path($new_path);
		$new_path = rtrim($new_path, '\\/').DS.$info['basename'];

		$return = $this->area->rename($this->path, $new_path);
		$return and $this->path = $new_path;

		return $return;
	}
801103
public function copy($path, $newpath)
    {
        $command = $this->s3Client->getCommand(
            'copyObject',
            [
                'Bucket'     => $this->bucket,
                'Key'        => $this->applyPathPrefix($newpath),
                'CopySource' => urlencode($this->bucket . '/' . $this->applyPathPrefix($path)),
                'ACL'        => $this->getRawVisibility($path) === AdapterInterface::VISIBILITY_PUBLIC
                    ? 'public-read' : 'private',
            ] + $this->options
        );

        try {
            $this->s3Client->execute($command);
        } catch (S3Exception $e) {
            return false;
        }

        return true;
    }
1364858
public function move(Filesystem $filesystem = null, $targetFilename = null, $overwrite = true)
    {
        // source file
        $sourceFile = $this->getTransport()->getFile();
        
        // target base name
        $targetBasename = $this->buildTargetBasename($sourceFile, $targetFilename);

        // move file to target storage
        $content = stream_get_contents($sourceFile->getStream());

        // write file
        $filesystem->write(
            $targetBasename,
            $content,
            $overwrite
        );

        return $filesystem->get($targetBasename);
    }
1342955
function nativeCopy($path, $newPath)
    {
        if (!$this->createDir(Util::dirname($newPath), new Config())) {
            return false;
        }

        $location    = $this->applyPathPrefix($this->encodePath($path));
        $newLocation = $this->applyPathPrefix($this->encodePath($newPath));

        try {
            $destination = $this->client->getAbsoluteUrl($newLocation);
            $response    = $this->client->request('COPY', '/' . ltrim($location, '/'), null, [
                'Destination' => $destination,
            ]);

            if ($response['statusCode'] >= 200 && $response['statusCode'] < 300) {
                return true;
            }
        } catch (NotFound $e) {
            // Would have returned false here, but would be redundant
        }

        return false;
    }