Exemplo n.º 1
0
            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();
            }
Exemplo n.º 2
0
        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));
                }
            }
        }
Exemplo n.º 3
0
 static string NormalizeSlashes(string path) => CurrentPlatform.NormalizeSlashes(path);
Exemplo n.º 4
0
 /// <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()));
 }
Exemplo n.º 5
0
 public ScriptInfo(int index, string path, TypeInfo script)
 {
     Index      = index;
     Path       = CurrentPlatform.NormalizeSlashes(path);
     MainMethod = CreateMain(script);
 }
Exemplo n.º 6
0
 /// <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));
 }