Generate and move file to specified path.

@param $path
@param $argument

@return string
193751
public function runFileGeneratorCommand($path, $argument)
    {
        if ($this->filesystem->exists($path)) {
            return 'File with the name '.$argument.' already exist';
        }
        $folder_name = explode('/', $argument);
        $folder = '';
        if (count($folder_name) > 1) {
            $folder_path = array_slice($folder_name, 0, -1);
            foreach ($folder_path as $f) {
                $folder .= "$f/";
            }
            $filename = end($folder_name);
        } else {
            $filename = $argument;
        }
        $folder ? $location = "$this->basePath/$folder/$filename.php" : $location = "$this->basePath/$filename.php";
        $template = $this->findTemplateAndReplacePlaceHolders('PlaceHolder', $filename,
            file_get_contents($this->getTemplate($this->type))
        );
        $this->filesystem->dumpFile($location, $template);

        return true;
    }
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;
    }
792463
public static function from($path)
    {
        switch( self::getFileExtension($path) )
        {
            case 'png' : return imagecreatefrompng($path);
            case 'gif' : return imagecreatefromgif($path);
            case 'jpg' :
            case 'jpeg':
            default    : return imagecreatefromjpeg($path);
        }
    }
1205474
public static function path(...$args)
    {
        static $dsds = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
        $result = implode(DIRECTORY_SEPARATOR, $args);
        $offset = strpos($result, '://');
        if(false === $offset)
        {
            $offset = 0;
        }
        else
        {
            $offset += 3;
        }
        while(false !== strpos($result, $dsds, $offset))
        {
            $result = str_replace($dsds, DIRECTORY_SEPARATOR, $result);
        }
        return $result;
    }
245337
private function buildCommand($command, $argument)
    {
        $command = sprintf($command, $argument);
        $this->output->writeln(
            'Calling following command:' . "\n" . $command,
            OutputInterface::VERBOSITY_DEBUG
        );

        return $command;
    }
477020
public function append($path)
    {
        //argument 1 must be a string
        $argument = Argument::i()->test(1, 'string');

        //each argument will be a path
        $paths = func_get_args();

        //for each path
        foreach ($paths as $i => $path) {
            //check for type errors
            $argument->test($i + 1, $path, 'string');
            //add to path
            $this->data .= $this->format($path);
        }

        return $this;
    }
181377
protected function escapeArgument($argument) : string
    {
        if (is_array($argument)) {
            $argument = array_map('escapeshellarg', $argument);
            $escaped  = implode(' ', $argument);
        } else {
            $escaped = escapeshellarg($argument);
        }
        return $escaped;
    }
1002590
protected function newPath(/*# string */ $path)/*# : Path */
    {
        list($mnt, $remain) = $this->splitPath($path);
        return new Path($path, $remain, $this->getFilesystemAt($mnt));
    }
1222639
public function moveUploadedFile(File $file, $path_pattern = null)
	{
		// inperpolate path_pattern using $file
		// and get interpolator result object

		$interpolated = $this->interpolator->resolveStorePath(
			$path_pattern ?: $this->getConfig('store.path_pattern', ''), $file);

		// file will be moved to interpolated path
		// using configured public_path as root

		$target = $this->getStoreRootPath() . '/' . ltrim($interpolated, '/');

		if ( ! file_exists($target))
		{
			$file->move(dirname($target), basename($target));
		}

		return $interpolated;
	}
675093
public function copyTo($path)
    {
        foreach ($this->assets as $assetName => $assetPath) {
            $outputPath = $path . '/' . $assetName;

            $this->copyFromTo($assetPath, $outputPath);
        }
    }
481208
private function getPhpFilesFromPath(string $path)
    {
        $directoryIterator = new RecursiveDirectoryIterator($path);
        foreach (new RecursiveIteratorIterator($directoryIterator) as $file) {
            if (! in_array($file->getExtension(), $this->fileExtensions)) {
                continue;
            }

            if ($this->fileShouldBeIgnored($file)) {
                continue;
            }

            $this->files->push(new File(['displayPath' => $file->getPathName(), 'fullPath' => $file->getRealPath()]));
        }
    }
712626
protected function moveFile( $context, $path )
	{
		$filename = basename( $path );
		$context->getFileSystemManager()->get( 'fs-admin' )->writef( $filename, $path );

		unlink( $path );
		return $filename;
	}
748794
protected function _prepareFilePath($path = null) {
		if (empty($path)) {
			return false;
		}

		if (DIRECTORY_SEPARATOR !== '\\') {
			return $path;
		}

		$path = str_replace('\\', '/', $path);

		return $path;
	}
275781
public function getUrl($path): string
    {
        \assert('is_string($path)');
        if (strpos($path, ':') === 0) {
            $key = substr($path, 0, strpos($path, '/') ?: \strlen($path));
            $path = $key === $path ? '' : (string)substr($path, \strlen($key));
        } else {
            $key = ':dist';
        }
        if (!isset($this->map[$key])) {
            throw new \InvalidArgumentException(sprintf('No path "%s" for subpackage "%s".', $path, $key));
        }
        return parent::getUrl(substr($key, 1) . $path);
    }
278870
public function get(string $path): File {
		return (new File(Paths::appendPath($this->getUrl(), $path)))->addFilters($this->recursiveFilter, true);
	}
779836
protected function generateAbsolutePath(string $root, string $path): ?string
    {
        if (false !== $absolute = realpath($root.DIRECTORY_SEPARATOR.$path)) {
            return $absolute;
        }

        return null;
    }
119912
protected function makeDirectory($path): string
    {
        if (! $this->laravel['files']->isDirectory($path)) {
            $this->laravel['files']->makeDirectory($path, 0777, true, true);
        }

        return $path;
    }