public CachedPhar(string pharFile, Type stubScriptType) { Assembly = stubScriptType.Assembly; PharFile = pharFile ?? GetPharFile(stubScriptType); Resources = new ResourceManager($"phar://{PharFile}", Assembly); Scripts = EnumeratePharScripts(stubScriptType.Assembly, PharFile) .Select(t => { var relpath = PharEntryRelativePath(t); Context.DeclareScript(relpath, Context.ScriptInfo.CreateMain(t)); return(CurrentPlatform.NormalizeSlashes(relpath)); }) .ToArray(); }
internal static IEnumerable <string> /*!*/ GetMatches(Context ctx, string /*!*/ pattern, GlobOptions flags) { if (string.IsNullOrEmpty(pattern)) { yield break; } var noEscape = (flags & GlobOptions.NoEscape) != 0; var brace = (flags & GlobOptions.Brace) != 0; var groups = UngroupGlobs(pattern, noEscape, brace); foreach (string group in groups) { var matcher = new GlobMatcher(ctx, group, flags); foreach (string filename in matcher.DoGlob()) { yield return(CurrentPlatform.NormalizeSlashes(filename)); } } }
static string NormalizeSlashes(string path) => CurrentPlatform.NormalizeSlashes(path);
/// <summary> /// Normalize slashes and ensures the path ends with slash. /// </summary> static string NormalizeRootPath(string path) { return(string.IsNullOrEmpty(path) ? string.Empty : CurrentPlatform.NormalizeSlashes(path.TrimEndSeparator())); }
public ScriptInfo(int index, string path, TypeInfo script) { Index = index; Path = CurrentPlatform.NormalizeSlashes(path); MainMethod = CreateMain(script); }
/// <summary> /// Gets relative path to the phar entry. /// The returned string is in form <c>{relative phar path}{DS}{phar entry path}</c> (e.g. <c>file.phar/dir/file.php</c>). /// </summary> public static string PharEntryRelativePath(string pharFile, string pharEntryPath) { return(CurrentPlatform.NormalizeSlashes(pharFile + CurrentPlatform.DirectorySeparator.ToString() + pharEntryPath)); }