Resolves an include name (either a filename or a classname) to a full pathname

@param string $include
@param string|array $includeDirs
@param boolean $className Whether $include can be a classname
@return string
163163
public static function resolveIncludePath($include, $includeDirs, $className = true)
    {
        $ns = null;
        $dirs = array();
        $include = trim($include, '\\');

        foreach ((array) $includeDirs as $includeNs => $includeDir) {
            if ($ns === null && is_numeric($includeNs)) {
                $dirs[] = $includeDir;
                continue;
            } else if (!$className) {
                continue;
            }
            $includeNs = trim($includeNs, '\\');
            if (substr($include, 0, strlen($includeNs)) === $includeNs) {
                if ($ns !== null && strlen($ns) > strlen($includeNs)) {
                    continue;
                }
                $ns = $includeNs;
                $dirs = $includeDir;
            }
        }

        if ($ns !== null) {
            $include = ltrim(substr($include, strlen($ns)), '\\');
        }
        $include = str_replace(array('_', '\\'), DIRECTORY_SEPARATOR, $include);
        return self::findFile("$include.php", $dirs);
    }
1027579
public static function getInclude($file, $namespace = null)
    {
        if (!$namespace && stripos($file, ".") === false) {
            $namespace = $file;
        }
        $file        = static::escapeText($file);
        $includeText = "#Include	{$file}";
        if ($namespace) {
            $includeText .= "	as {$namespace}";
        }
        return $includeText . "
";
    }
753043
private function resolveFilePath($path)
    {
        $path = str_replace(array($this->_protocol.'://', '/'), array('', DIRECTORY_SEPARATOR), $path);

        foreach ($this->_includeExtensions as $ext) {
            $filename = $path.$ext;
            File::resolveFilepath($filename, null, array('include_path' => $this->_classcontentdir));
            if (true === is_file($filename)) {
                return $filename;
            }
        }

        return $path;
    }
380685
public function export_to_file($filename, $include_headers = true)
    {
        $fh = fopen($filename, 'w');
        if (false === $fh) {
            return false;
        }
        $export = $this->export($include_headers);
        $res = fwrite($fh, $export);
        if (false === $res) {
            return false;
        }

        return fclose($fh);
    }
301159
public function resolveClassName($className)
    {

        if (isset($this->_aliases[$className]))
            $className = $this->_aliases[$className];

        return $className;
    }
1112365
public static function includePath($paths) {
        $current = array(get_include_path());

        if (is_array($paths)) {
            $current = array_merge($current, $paths);
        } else {
            $current[] = $paths;
        }

        $path = implode(static::DELIMITER, $current);

        set_include_path($path);

        return $path;
    }
671571
public function getChildren($includeDeleted = false)
    {
        if ($includeDeleted) {
            return $this->children;
        }

        return $this->children->filter(function (Folder $entry) {
            if ($entry->isDeleted()) {
                return false;
            }

            return true;
        });
    }
323859
public function resolve(ClassName $className)
    {
        if ($className->isAbsolute()) {
            return $className;
        } elseif ($className->isShortName()) {
            $usedClass = $this->usedClass($className);
            if (null !== $usedClass) {
                return $usedClass;
            }
        }

        if (null !== $this->namespaceName()) {
            return $this->namespaceName()->join($className);
        }

        return $className->toAbsolute();
    }
1069405
public function saveInclude($include_name, array $include_fields = [ ]) {
        $data = $include_fields;
        $data['include'] = $include_name;
        return $this->apiPost('include', $data);
    }
678848
function includedFile(fileName) {
            var relativePath = fileName.substring(appDir.length + 1);
            var result = false;
            for (var i = 0; i < onlyIncludeList.length; i++) {
                var prefix = onlyIncludeList[i];
                if (relativePath.indexOf(prefix) === 0) {
                    result = true;
                    break;
                }
            }
            return result;
        }
632703
private String getAdditionalIncludeDirectories(final String baseDir,
      final CommandLineCompilerConfiguration compilerConfig) {
    final File[] includePath = compilerConfig.getIncludePath();
    final StringBuffer includeDirs = new StringBuffer();
    // Darren Sargent Feb 10 2010 -- reverted to older code to ensure sys
    // includes get, erm, included
    final String[] args = compilerConfig.getPreArguments();

    for (final String arg : args) {
      if (arg.startsWith("/I")) {
        includeDirs.append(arg.substring(2));
        includeDirs.append(';');
      }

    }
    // end Darren

    if (includeDirs.length() > 0) {
      includeDirs.setLength(includeDirs.length() - 1);
    }
    return includeDirs.toString();
  }
1025308
public static function asset($relative_path, $include_version=true) {
    $clean_relative_path = preg_replace('/^[\/_]+/', '', $relative_path);
    return sprintf(
      '%s/_/%s%s',
      THEME_URL,
      $clean_relative_path,
      ($include_version) ? THEME_SUFFIX : null
    );
  }
1123638
public function get_files($includedirs = true, $updatedsince = 0) {

        $lesson = lesson::load($this->properties->lessonid);
        $fs = get_file_storage();
        $answerfiles = $fs->get_area_files($lesson->context->id, 'mod_lesson', 'page_answers', $this->properties->id,
                                            'itemid, filepath, filename', $includedirs, $updatedsince);
        $responsefiles = $fs->get_area_files($lesson->context->id, 'mod_lesson', 'page_responses', $this->properties->id,
                                            'itemid, filepath, filename', $includedirs, $updatedsince);
        return array_merge($answerfiles, $responsefiles);
    }
522103
public function get_files($includedirs = true, $updatedsince = 0) {
        $fs = get_file_storage();
        return $fs->get_area_files($this->lesson->context->id, 'mod_lesson', 'page_contents', $this->properties->id,
                                    'itemid, filepath, filename', $includedirs, $updatedsince);
    }
1258433
public function classname_to_path( $classname ) {
		// Convert the namespace to a sub-directory path
		if ( strpos( $classname, '\\' ) !== false) {
			$classname = str_replace( '\\', DIRECTORY_SEPARATOR, $classname );
		}

		return $classname;
	}
444463
private function filesWithFullPaths($dir, $include_hidden = true, $recursive = false)
    {
        $dir = $this->withSlash($dir);

        $result = [];

        if ($dirstream = opendir($dir)) {
            while (false !== ($filename = readdir($dirstream))) {
                $path = $dir . $filename;

                if ($filename != '.' && $filename != '..') {
                    if (is_dir($path)) {
                        if ($recursive) {
                            $files_from_subdir = $this->filesWithFullPaths($path, $recursive);

                            if (is_array($files_from_subdir)) {
                                $result = array_merge($result, $files_from_subdir);
                            }
                        }
                    } else {
                        if (is_file($path) || (is_link($path) && is_file(readlink($path)))) {
                            if (mb_substr($filename, 0, 1) == '.' && !$include_hidden) {
                                continue;
                            }

                            $result[] = $path;
                        }
                    }
                }
            }
        }

        closedir($dirstream);

        return $result;
    }
795102
public function include($includes)
	{
		$model = $this;

		(function() use ($includes, $model): void
		{
			$this->including($includes)->loadIncludes([$model]);
		})->bindTo($this->builder(), Query::class)();

		return $this;
	}