Import file

@param string $path
@param array  $out
760983
protected function importFile($path, $out)
    {
        // see if tree is cached
        $realPath = realpath($path);

        if (isset($this->importCache[$realPath])) {
            $this->handleImportLoop($realPath);

            $tree = $this->importCache[$realPath];
        } else {
            $code   = file_get_contents($path);
            $parser = $this->parserFactory($path);
            $tree   = $parser->parse($code);

            $this->importCache[$realPath] = $tree;
        }

        $pi = pathinfo($path);
        array_unshift($this->importPaths, $pi['dirname']);
        $this->compileChildrenNoReturn($tree->children, $out);
        array_shift($this->importPaths);
    }
1212202
public function compile($input, $path = null)
    {
        $compileEvent = new CompileEvent($input, $path ?: $this->getOption('filename'));
        $this->trigger($compileEvent);

        $input = $compileEvent->getInput();
        $path = $compileEvent->getPath();
        $this->importPaths = [];
        $includes = [];
        foreach ($this->getOption('includes') as $include) {
            $includes[] = $this->compileDocument(file_get_contents($include), $include);
        }

        $element = $this->compileDocument($input, $path);

        foreach (array_reverse($includes) as $include) {
            $element->prependChild($include);
        }

        $output = $this->getFormatter()->format($element);
        $output = $this->getFormatter()->formatDependencies().$output;

        $outputEvent = new OutputEvent($compileEvent, $output);
        $this->trigger($outputEvent);

        return $outputEvent->getOutput();
    }
164803
private function LoadFromPHP($path)
    {
        $this->definitions_path = rtrim($path, "/\\") . "/";
        $this->import_type = Type::PHP;
        
        // This variable is used by the php definition files to reference
        // this object and populate it with elements.
        $symbols =& $this->symbols;
        
        if(file_exists($this->definitions_path . "constants.php"))
        {
            $this->SendMessage(t("Loading constants.php"));
            include($this->definitions_path . "constants.php");
        }
        
        if(file_exists($this->definitions_path . "enumerations.php"))
        {
            $this->SendMessage(t("Loading enumerations.php"));
            include($this->definitions_path . "enumerations.php");
        }
        
        if(file_exists($this->definitions_path . "type_definitions.php"))
        {
            $this->SendMessage(t("Loading type_definitions.php"));
            include($this->definitions_path . "type_definitions.php");
        }
        
        if(file_exists($this->definitions_path . "variables.php"))
        {
            $this->SendMessage(t("Loading variables.php"));
            include($this->definitions_path . "variables.php");
        }
        
        if(file_exists($this->definitions_path . "functions.php"))
        {
            $this->SendMessage(t("Loading functions.php"));
            include($this->definitions_path . "functions.php");
        }
        
        if(file_exists($this->definitions_path . "classes.php"))
        {
            $this->SendMessage(t("Loading classes.php"));
            include($this->definitions_path . "classes.php");
        }
    }
884651
public static function createWithoutLoop(Path $path, int $from, int $to): Path
    {
        $fromPlaces = $path->getPlacesAt($from);
        $toPlaces = $path->getPlacesAt($to);
        if (!array_diff($fromPlaces, $toPlaces)) {
            return static::create($path, $from, $to, [], [], []);
        } else {
            throw new Exception('Can not create new path without loop');
        }
    }
309483
public function onFileChanged($path)
    {
        if (!Daemon::lintFile($path)) {
            Daemon::log(__METHOD__ . ': Detected parse error in ' . $path);
            return;
        }
        foreach ($this->files[$path] as $cb) {
            if (is_callable($cb) || is_array($cb)) {
                $cb($path);
            } elseif (!Daemon::$process->IPCManager->importFile($cb, $path)) {
                $this->rmWatch($path, $cb);
            }
        }
    }
675093
public function copyTo($path)
    {
        foreach ($this->assets as $assetName => $assetPath) {
            $outputPath = $path . '/' . $assetName;

            $this->copyFromTo($assetPath, $outputPath);
        }
    }
1348513
function (path, currentFileInfo, importOptions, callback) {
            var parserImports = this;
            this.queue.push(path);

            var fileParsedFunc = function (e, root, fullPath) {
                parserImports.queue.splice(parserImports.queue.indexOf(path), 1); // Remove the path from the queue

                var importedPreviously = fullPath in parserImports.files || fullPath === rootFilename;

                parserImports.files[fullPath] = root;                        // Store the root

                if (e && !parserImports.error) { parserImports.error = e; }

                callback(e, root, importedPreviously, fullPath);
            };

            if (less.Parser.importer) {
                less.Parser.importer(path, currentFileInfo, fileParsedFunc, env);
            } else {
                less.Parser.fileLoader(path, currentFileInfo, function(e, contents, fullPath, newFileInfo) {
                    if (e) {fileParsedFunc(e); return;}

                    var newEnv = new tree.parseEnv(env);

                    newEnv.currentFileInfo = newFileInfo;
                    newEnv.processImports = false;
                    newEnv.contents[fullPath] = contents;

                    if (currentFileInfo.reference || importOptions.reference) {
                        newFileInfo.reference = true;
                    }

                    if (importOptions.inline) {
                        fileParsedFunc(null, contents, fullPath);
                    } else {
                        new(less.Parser)(newEnv).parse(contents, function (e, root) {
                            fileParsedFunc(e, root, fullPath);
                        });
                    }
                }, env);
            }
        }
154423
public function import($src, $path, $message)
    {
        if (!$this->hasCheckout) {
            $this->checkout();
        }

        $filesystem = new Filesystem();
        $filesystem->mirror($src, $this->cwd . $path);

        $test = $this->add('*');
        $test = $this->commit($message);
    }
474669
protected function compileChild($child, \Leafo\ScssPhp\Formatter\OutputBlock $out) {
        switch($child[0]) {
            case \Leafo\ScssPhp\Type::T_SCSSPHP_IMPORT_ONCE:
            case \Leafo\ScssPhp\Type::T_IMPORT:
                list(, $rawpath) = $child;
                $rawpath = $this->reduce($rawpath);
                $path = $this->compileStringContent($rawpath);
                if ($path = $this->findImport($path)) {
                    if ($this->is_valid_file($path)) {
                        return parent::compileChild($child, $out);
                    } else {
                        // Sneaky stuff, don't let non scss file in.
                        debugging("Can't import scss file - " . $path, DEBUG_DEVELOPER);
                    }
                }
                break;
            default:
                return parent::compileChild($child, $out);
        }
    }
1029507
public function createDefault($path, $width = 430, $outType = null)
    {
        $url = 'https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=ACCESS_TOKEN';
        $this->registerApi($url, __FUNCTION__, func_get_args());
        $result = Tools::post($url, Tools::arr2json(['path' => $path, 'width' => $width]));
        if (json_decode($result)) {
            return Tools::json2arr($result);
        }
        return is_null($outType) ? $result : $outType($result);
    }
8639
public function importSql($path, $files = array('setup_structure.sql'))
    {
        $status = false;
        $fImport = null;
        if(file_exists($path)) {
            foreach($files as $file) {
                if(file_exists($path.$file)) {
                    $fImport = file_get_contents($path.$file);
                    $this->executeRawQuery($fImport);
                    $this->importTableName = array_merge($this->importTableName, $this->getSqlFileTables($path.$file));
                }
            }
        }

        return $status;
    }
995640
public static function createWithoutTransition(Path $path, int $from, int $to): Path
    {
        $fromPlaces = $path->getPlacesAt($from);
        $toPlaces = $path->getPlacesAt($to);
        if (count($fromPlaces) > 1 && count($toPlaces) > 1 && 1 === count(array_diff($fromPlaces, $toPlaces)) &&
            1 === count(array_diff($toPlaces, $fromPlaces))) {
            $path = static::create($path, $from, $to, [], [], []);

            $find = array_values(array_diff($toPlaces, $fromPlaces))[0];
            $replace = array_values(array_diff($fromPlaces, $toPlaces))[0];
            for ($i = $to; $i < $path->countPlaces(); ++$i) {
                $places = $path->getPlacesAt($i);
                $key = array_search($find, $places);
                $newPlaces = array_replace($places, [$key => $replace]);
                $path->setPlacesAt($i, $newPlaces);
            }

            return $path;
        } else {
            throw new Exception('Can not create new path without transition');
        }
    }
1322601
protected static function parsePathToTree( $path, array &$into ) {
		if( $path === '' ) return;
		if( is_string($path) ) $path = explode('.', $path);
		if( count($path) == 0 ) return;
		
		if( !isset($into[$path[0]]) ) {
			$into[$path[0]] = array();
		}
		
		self::parsePathToTree( array_slice($path, 1), $into[$path[0]] );
	}
764620
@WithBridgeMethods(value = MySQLQuery.class, castRequired = true)
    public C intoOutfile(File file) {
        return addFlag(Position.END, "\ninto outfile '" + file.getPath() + "'");
    }
466941
protected function canImportFile($path)
    {
        $parsed = parse_url($path);
        if (
            // file is elsewhere
            isset($parsed['host']) ||
            // file responds to queries (may change, or need to bypass cache)
            isset($parsed['query'])
        ) {
            return false;
        }

        return strlen($path) < PHP_MAXPATHLEN && @is_file($path) && is_readable($path);
    }
500709
protected function compileImport($rawPath, $out) {
        if ($rawPath[0] == "string") {
            $path = $this->compileStringContent($rawPath);
            if ($path = $this->findImport($path)) {
                $this->importFile($path, $out);
                return true;
            }
            return false;
        } if ($rawPath[0] == "list") {
            // handle a list of strings
            if (count($rawPath[2]) == 0) return false;
            foreach ($rawPath[2] as $path) {
                if ($path[0] != "string") return false;
            }

            foreach ($rawPath[2] as $path) {
                $this->compileImport($path, $out);
            }

            return true;
        }

        return false;
    }
86005
private function load_file( $path ) {
		if ( $path && is_readable( $path ) ) {
			include_once( $path );
			$success = true;
		}

		return ! ( empty( $success ) ) ? true : false;
	}