Exemple #1
0
    static void Main(string[] args)
    {
        Target(Clean,
               ForEach("**/bin", "**/obj"),
               dir =>
        {
            IEnumerable <string> GetDirectories(string d)
            {
                return(Glob.Directories(".", d));
            }

            void RemoveDirectory(string d)
            {
                if (Directory.Exists(d))
                {
                    Console.WriteLine(d);
                    Directory.Delete(d, true);
                }
            }

            foreach (var d in GetDirectories(dir))
            {
                RemoveDirectory(d);
            }
        });

        Target(Build, ForEach("net46", "netstandard2.0", "netstandard2.1"),
               framework =>
        {
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && framework == "net46")
            {
                return;
            }
            Run("dotnet", "build src/SharpCompress/SharpCompress.csproj -c Release");
        });

        Target(Test, DependsOn(Build), ForEach("netcoreapp3.1"),
               framework =>
        {
            IEnumerable <string> GetFiles(string d)
            {
                return(Glob.Files(".", d));
            }

            foreach (var file in GetFiles("**/*.Test.csproj"))
            {
                Run("dotnet", $"test {file} -c Release -f {framework} --no-restore --no-build");
            }
        });

        Target(Publish, DependsOn(Test),
               () =>
        {
            Run("dotnet", "pack src/SharpCompress/SharpCompress.csproj -c Release -o artifacts/");
        });

        Target("default", DependsOn(Publish), () => Console.WriteLine("Done!"));

        RunTargetsAndExit(args);
    }
Exemple #2
0
        public void StarStarFiles()
        {
            Action <string> AssertEqual(string expected) => actual => Assert.Equal(expected, actual);

            var testRoot = Path.Combine(Path.GetTempPath(), "Glob", "PathTraverserTests", "StarStarFiles");

            try
            {
                CreateFiles(testRoot, "ab/bin/a.cs ab/bin/sub/a.cs a/taco.cs b/taco.cs b/ab/a/hat.taco");

                // Verify files exist before
                Assert.True(File.Exists(Path.Combine(testRoot, "a/taco.cs")));
                Assert.True(File.Exists(Path.Combine(testRoot, "ab/bin/a.cs")));
                Assert.True(File.Exists(Path.Combine(testRoot, "ab/bin/sub/a.cs")));
                Assert.True(File.Exists(Path.Combine(testRoot, "b/ab/a/hat.taco")));
                Assert.True(File.Exists(Path.Combine(testRoot, "b/taco.cs")));

                Assert.Collection(Glob.Files(testRoot, "**").OrderBy(x => x),
                                  AssertEqual(Path.Combine("a", "taco.cs")),
                                  AssertEqual(Path.Combine("ab", "bin", "a.cs")),
                                  AssertEqual(Path.Combine("ab", "bin", "sub", "a.cs")),
                                  AssertEqual(Path.Combine("b", "ab", "a", "hat.taco")),
                                  AssertEqual(Path.Combine("b", "taco.cs"))
                                  );
            }
            finally
            {
                // Cleanup test
                Directory.Delete(testRoot, true);
            }
        }
        /// <summary>
        /// Copies the files matching the specified globs from one directory to another, creating subdirectories as needed.
        /// </summary>
        /// <param name="fromDirectory">The source directory.</param>
        /// <param name="toDirectory">The target directory.</param>
        /// <param name="globs">The globs to match. Use <c>"**"</c> to copy all files and directories.</param>
        public static void CopyFiles(string fromDirectory, string toDirectory, params string[] globs)
        {
            if (fromDirectory == null)
            {
                throw new ArgumentNullException(nameof(fromDirectory));
            }
            if (toDirectory == null)
            {
                throw new ArgumentNullException(nameof(toDirectory));
            }
            if (globs == null)
            {
                throw new ArgumentNullException(nameof(globs));
            }

            foreach (var filePath in globs.SelectMany(glob => Glob.Files(fromDirectory, glob, GlobOptions.CaseInsensitive)).Distinct())
            {
                if (Path.GetDirectoryName(filePath) is string directoryName)
                {
                    Directory.CreateDirectory(Path.Combine(toDirectory, directoryName));
                }

                File.Copy(Path.Combine(fromDirectory, filePath), Path.Combine(toDirectory, filePath));
            }
        }
Exemple #4
0
        public void Issue59MultipleEnumerationsReturnSameResults()
        {
            var testRoot = Path.Combine(Path.GetTempPath(), "Glob", "PathTraverserTests", "Issue59MultipleEnumerationsReturnSameResults");

            try
            {
                CreateFiles(testRoot, "b/a taco.txt a/b");

                var allFiles    = Glob.Files(testRoot, "**").OrderBy(x => x);
                var enumerator1 = allFiles.GetEnumerator();

                AssertEnumerator(enumerator1, Path.Combine("a", "b"));
                AssertEnumerator(enumerator1, Path.Combine("b", "a"));
                AssertEnumerator(enumerator1, "taco.txt");

                Assert.False(enumerator1.MoveNext());

                // second enumeration should emit same results
                var enumerator2 = allFiles.GetEnumerator();

                AssertEnumerator(enumerator2, Path.Combine("a", "b"));
                AssertEnumerator(enumerator2, Path.Combine("b", "a"));
                AssertEnumerator(enumerator2, "taco.txt");

                Assert.False(enumerator2.MoveNext());
            }
            finally
            {
                // Cleanup test
                Directory.Delete(testRoot, true);
            }
        }
        public static void Restore()
        {
            LOG.Debug("Restoring Settings");

            var currentSettingsFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath;

            LOG.Debug($"Current Settings File: {currentSettingsFile}");

            var localAppData = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData));
            var settingsFile = Glob.Files(localAppData, "Tabbed*TortoiseGit/Tabbed*TortoiseGit*/*/user.config")
                               .Where((f) => f.FullName != currentSettingsFile)
                               .OrderBy((f) => f.LastWriteTime)
                               .LastOrDefault();

            LOG.Debug($"Previous Settings File: {settingsFile?.FullName}");

            if (settingsFile != null)
            {
                LOG.Debug("Copying previous settings file to current settings file");
                Directory.CreateDirectory(Path.GetDirectoryName(currentSettingsFile) !);
                settingsFile.CopyTo(currentSettingsFile, true);

                LOG.Debug("Reloading settings");
                Settings.Default.Reload();
            }
        }
Exemple #6
0
    // Start is called before the first frame update
    void Start()
    {
        musicFolderPath = musicFolderPath.Replace('\\', '/');
        matchingFiles   = Glob.Files($"{musicFolderPath}", "*.wav").ToArray();

        foreach (string path in matchingFiles)
        {
            StartCoroutine(LoadAudio(musicFolderPath + "/" + path));
        }
    }
Exemple #7
0
        public void CanMatchFilesInDirectoriesWithTrailingSlash()
        {
            var globPattern = @"**/*Gl*.Te*";
            var root        = new DirectoryInfo(SourceRoot + Path.DirectorySeparatorChar).FullName;
            var result      = Glob.Files(root, globPattern).ToList();

            Assert.NotNull(result);
            Assert.All(result, path => Assert.StartsWith("test", path));
            Assert.True(result.Any(), $"There should be some directories that match glob: {globPattern} in '{root}'");
        }
Exemple #8
0
 protected override void ConfigureBuildProperties(IBuildPropertiesContext context)
 {
     context.Properties.Set(BuildProps.ProductId, "CAP");
     context.Properties.Set(BuildProps.SolutionFileName, "CAP.sln");
     context.Properties.Set(BuildProps.BuildConfiguration, string.IsNullOrEmpty(Configuration) ? "Release" : Configuration);
     //// todo remove casting when new version of flubu is available
     BuildVersion = FetchBuildVersion(context as ITaskContext);
     Console.WriteLine(BuildVersion.Version());
     TestProjectFiles = Glob.Files("./test", "*/*.csproj", GlobOptions.MatchFullPath).Select(x => $"./test/{x}").ToList();
     ProjectFiles     = Glob.Files("./src", "*/*.csproj").Select(x => $"./src/{x}").ToList();
 }
    static void Main(string[] args)
    {
        Target(Clean,
               ForEach("publish", "**/bin", "**/obj"),
               dir =>
        {
            IEnumerable <string> GetDirectories(string d)
            {
                return(Glob.Directories(".", d));
            }

            void RemoveDirectory(string d)
            {
                if (Directory.Exists(d))
                {
                    Console.WriteLine($"Cleaning {d}");
                    Directory.Delete(d, true);
                }
            }

            foreach (var d in GetDirectories(dir))
            {
                RemoveDirectory(d);
            }
        });

        Target(Build, () => Run("dotnet", "build . -c Release"));

        Target(Test, DependsOn(Build),
               () =>
        {
            IEnumerable <string> GetFiles(string d)
            {
                return(Glob.Files(".", d));
            }

            foreach (var file in GetFiles("tests/**/*.csproj"))
            {
                Run("dotnet", $"test {file} -c Release --no-restore --no-build --verbosity=normal");
            }
        });

        Target(Publish, DependsOn(Test),
               ForEach("src/Conduit"),
               project =>
        {
            Run("dotnet",
                $"publish {project} -c Release -f netcoreapp3.1 -o ./publish --no-restore --no-build --verbosity=normal");
        });

        Target("default", DependsOn(Publish), () => Console.WriteLine("Done!"));
        RunTargetsAndExit(args);
    }
Exemple #10
0
        /// <summary>
        /// Finds the files matching the specified globs.
        /// </summary>
        /// <param name="directory">The starting directory.</param>
        /// <param name="globs">The globs to match.</param>
        /// <returns>The paths of the matching files.</returns>
        public static IReadOnlyList <string> FindFilesFrom(string directory, params string[] globs)
        {
            if (directory == null)
            {
                throw new ArgumentNullException(nameof(directory));
            }
            if (globs == null)
            {
                throw new ArgumentNullException(nameof(globs));
            }

            return(globs.SelectMany(glob => Glob.Files(directory, glob, GlobOptions.CaseInsensitive)).Distinct().Select(path => Path.Combine(directory, path)).ToList());
        }
        private int OnExecute()
        {
            // var project = new Project();
            // project.groups = new List<ProjectGroup>();
            // project.groups.Add(new ProjectGroup() { name = "Render", })


            if (!File.Exists(manifest))
            {
                Console.WriteLine($"Could not find manifest file [{manifest}].");
                return(-1);
            }

            using (var fs = File.OpenRead(manifest))
            {
                var dir = Path.GetDirectoryName(manifest);

                var m = Utf8Json.JsonSerializer.Deserialize <Manifest>(fs);
                foreach (var g in m.groups)
                {
                    if (Path.IsPathRooted(g.path) || g.path.Contains(".."))
                    {
                        Console.WriteLine("Path must be relative and a subdirectory.");
                        return(-1);
                    }

                    Console.WriteLine(g.name);

                    var workingDir = Path.Combine(dir, g.path);
                    foreach (var file in Glob.Files(workingDir, "*.json", GlobOptions.CaseInsensitive))
                    {
                        if (ProcessFile(m, g, Path.Combine(workingDir, file)) != 0)
                        {
                            return(-1);
                        }
                        Console.WriteLine(" " + file);
                    }
                }
            }

            // foreach (var file in Glob.Files(workingDir, search, GlobOptions.CaseInsensitive))
            // {
            //     if (ProcessFile(file) != 0)
            //         return -1;
            //     //WriteLine(file);
            // }

            return(0);
        }
Exemple #12
0
        /// <summary>
        /// Copies the files matching the specified globs from one directory to another, creating subdirectories as needed.
        /// </summary>
        /// <param name="fromDirectory">The source directory.</param>
        /// <param name="toDirectory">The target directory.</param>
        /// <param name="globs">The globs to match. Use <c>"**"</c> to copy all files and directories.</param>
        public static void CopyFiles(string fromDirectory, string toDirectory, params string[] globs)
        {
            if (fromDirectory == null)
            {
                throw new ArgumentNullException(nameof(fromDirectory));
            }
            if (toDirectory == null)
            {
                throw new ArgumentNullException(nameof(toDirectory));
            }
            if (globs == null)
            {
                throw new ArgumentNullException(nameof(globs));
            }

            CopyFilesCore(fromDirectory, toDirectory, globs.SelectMany(glob => Glob.Files(fromDirectory, glob, GlobOptions.CaseInsensitive)).Distinct());
        }
        /// <summary>
        /// Creates a new plugin loader
        /// </summary>
        /// <param name="root">root folder, default is relative to executing assemlby</param>
        /// <param name="patterns"></param>
        public PluginLoader(ILogger logger = null, string rootDir = ".", IEnumerable <string> patterns = null)
        {
            logger.LogDebug("Getting files from {relpath}", rootDir);
            var files = new List <string>();

            if (patterns == null)
            {
                files.AddRange(Glob.Files(rootDir, "**/*.dll"));
            }
            else
            {
                foreach (var pattern in patterns)
                {
                    files.AddRange(Glob.Files(rootDir, Regex.Replace(pattern, @"^\./", "")));
                }
            }

            logger.LogDebug("Found {fct} files:\n {@files}", files.Count, files);

            var builder = new ReflectionMetadataBuilder();

            foreach (var file in files)
            {
                try
                {
                    builder.AddAssembly(Path.Combine(rootDir, file));
                }
                catch (Exception)
                {
                }
            }

            builder.AddReferenceOnlyAssemblyByType <object>(); // adds the corlib
            try
            {
                metaData = builder.Build(true);
            }
            catch (AggregateException aex)
            {
                throw;
            }
            catch (Exception ex)
            {
            }
        }
Exemple #14
0
        private static bool VerifyReportFileAndExpandGlobPatterns(string path, out IEnumerable <string> expanded)
        {
            expanded = null;

            if (string.IsNullOrWhiteSpace(path))
            {
                Log.Warning("Invalid report path.");
                return(false);
            }

            if (path.Contains('*') ||
                path.Contains('?') ||
                path.Contains('!') ||
                path.Contains(','))
            {
                string directory;
                string pattern;
                if (Path.IsPathRooted(path))
                {
                    directory = Path.GetPathRoot(path);
                    pattern   = path.Substring(directory.Length);
                }
                else
                {
                    directory = Environment.CurrentDirectory;
                    pattern   = path;
                }

                expanded = Glob.Files(directory, pattern, GlobOptions.Compiled | GlobOptions.CaseInsensitive)
                           .Select(x => Path.Combine(directory, x))
                           .Distinct();

                return(true);
            }
            else if (!File.Exists(path))
            {
                Log.Warning("The file {path} does not exist.", path);
                return(false);
            }

            expanded = new[] { path };
            return(true);
        }
Exemple #15
0
        private static bool VerifyReportFileAndExpandGlobPatterns(string path, out IEnumerable <string> expandedPath)
        {
            var expanded = new HashSet <string> {
                path
            };

            expandedPath = expanded;
            if (string.IsNullOrWhiteSpace(path))
            {
                Logger.Log.Warning("Invalid report path.");
                return(false);
            }

            if (path.Contains('*') ||
                path.Contains('?') ||
                path.Contains('!') ||
                path.Contains(','))
            {
                // Logger.Log.Information($"Using wildcard path {path}");
                var matches = Glob.Files(Environment.CurrentDirectory, path, GlobOptions.Compiled | GlobOptions.CaseInsensitive)?.ToList();
                if (matches?.Any() != true)
                {
                    // Logger.Log.Warning($"There are no files that match the wildcard {path}.");
                    return(false);
                }

                expanded.Clear();
                matches.ForEach(_ =>

                                // Logger.Log.Information($"Adding file {_} that matches wildcard path {path}");
                                expanded.Add(_));

                return(true);
            }
            else if (!File.Exists(path))
            {
                Logger.Log.Warning($"The file {path} does not exist.");
                return(false);
            }

            return(true);
        }
Exemple #16
0
        void RunWithSingleEntry(string inputPath)
        {
            if (Directory.Exists(inputPath))
            {
                foreach (var fileName in Directory.EnumerateFiles(inputPath))
                {
                    RunWithSingleFileSafe(Path.Combine(inputPath, fileName));
                }
            }
            else if (File.Exists(inputPath))
            {
                RunWithSingleFileSafe(inputPath);
            }
            else
            {
                var specialCharPos = inputPath.IndexOfAny("*?[{".ToCharArray());
                if (specialCharPos < 0)
                {
                    throw new BinariexException("finding source file", "Input file not found.").AddInputPath(inputPath);
                }

                var sepCharPos = inputPath.LastIndexOf(Path.DirectorySeparatorChar, specialCharPos);
                if (sepCharPos < 0)
                {
                    throw new BinariexException("finding source file", "Need directory path before wildcard.").AddInputPath(inputPath);
                }

                var rootDirPath = inputPath.Substring(0, sepCharPos);
                if (!Directory.Exists(rootDirPath))
                {
                    throw new BinariexException("finding source file", "Input file not found.").AddInputPath(inputPath);
                }

                foreach (var file in Glob.Files(new DirectoryInfo(rootDirPath), inputPath.Substring(sepCharPos + 1)))
                {
                    RunWithSingleFileSafe(file.FullName);
                }
            }
        }
Exemple #17
0
        public void Issue59MissingFiles()
        {
            Action <string> AssertEqual(string expected) => actual => Assert.Equal(expected, actual);

            var testRoot = Path.Combine(Path.GetTempPath(), "Glob", "PathTraverserTests", "Issue59MissingFiles");

            try
            {
                CreateFiles(testRoot, "test1.txt deep/test2.txt");

                var allFiles = Glob.Files(testRoot, "**/*.txt").OrderBy(x => x).ToList();
                Assert.Collection(allFiles,
                                  AssertEqual(Path.Combine("deep", "test2.txt")),
                                  AssertEqual("test1.txt")
                                  );
            }
            finally
            {
                // Cleanup test
                Directory.Delete(testRoot, true);
            }
        }
Exemple #18
0
        public void StarStarFilesIssue52()
        {
            Action <string> AssertEqual(string expected) => actual => Assert.Equal(expected, actual);

            var testRoot = Path.Combine(Path.GetTempPath(), "Glob", "PathTraverserTests", "StarStarFilesIssue52");

            try
            {
                CreateFiles(testRoot, "a/a/a/a/b.txt");

                // Verify files exist before
                Assert.True(File.Exists(Path.Combine(testRoot, "a/a/a/a/b.txt")));

                Assert.Collection(Glob.Files(testRoot, "**/a/**/b.txt").OrderBy(x => x),
                                  AssertEqual(Path.Combine("a", "a", "a", "a", "b.txt"))
                                  );
            }
            finally
            {
                // Cleanup test
                Directory.Delete(testRoot, true);
            }
        }
Exemple #19
0
        public void Configure(IApophysisNative apophysis)
        {
            foreach (var glob in Plugin ?? new string[0])
            {
                var dir     = Path.IsPathRooted(glob) ? Regex.Replace(glob, "^(.+?)\\*.*$", "$1") : Environment.CurrentDirectory;
                var pattern = Path.IsPathRooted(glob) ? glob.Substring(dir.Length) : glob;

                foreach (var file in Glob.Files(dir, pattern, GlobOptions.MatchFullPath))
                {
                    _outputManager.Log($"Loading plugin: {file}");
                    apophysis.InitializePlugin(Path.Combine(dir, file));
                }
            }

            using (var sr = new StreamReader(OpenInputStream()))
            {
                apophysis.Parameters = sr.ReadToEnd();
            }

            apophysis.ImageFormat     = ImageFormat;
            apophysis.ImageSize       = ImageSize;
            apophysis.SamplesPerPixel = Quality;
            apophysis.ThreadingLevel  = Threads;
        }
Exemple #20
0
        private static void Run(ArgsReader args)
        {
            var workingDirectory = args.ReadOption("w") ?? Environment.CurrentDirectory;
            var arguments        = args.ReadArguments().ToList();

            var globIndex = arguments.FindIndex(x => x.IndexOfAny(new[] { '*', '?', '[', '{' }) != -1);

            void LaunchFile(string filePath)
            {
                var processArgs = arguments.Take(globIndex).Append(filePath).Concat(arguments.Skip(globIndex + 1)).ToList();

                var processStartInfo = new ProcessStartInfo
                {
                    FileName         = processArgs[0],
                    WorkingDirectory = workingDirectory,
                    UseShellExecute  = true,
                };

                foreach (var processArg in processArgs.Skip(1))
                {
                    processStartInfo.ArgumentList.Add(processArg);
                }
                Process.Start(processStartInfo);
            }

            if (arguments.Count == 0)
            {
                ShowMessageBox(
                    "Usage: LaunchGlob <args...> [options] [-- <args...>]",
                    "",
                    "One argument must be a glob (e.g. *.sln). If there is one match,",
                    "it will be launched immediately; otherwise, choose from the prompt.",
                    "",
                    "Options:",
                    "  -w <working-directory>");
            }
            else if (globIndex == -1)
            {
                ShowMessageBox("Error: glob not found in arguments.");
            }
            else
            {
                var glob      = arguments[globIndex];
                var filePaths = Glob.Files(workingDirectory, glob, GlobOptions.CaseInsensitive).ToList();
                if (filePaths.Count == 0)
                {
                    ShowMessageBox(
                        "File not found!",
                        "",
                        $"Glob: {glob}",
                        $"Directory: {workingDirectory}");
                }
                else if (filePaths.Count == 1)
                {
                    LaunchFile(filePaths[0]);
                }
                else
                {
                    var listBox = new ListBox
                    {
                        Anchor     = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
                        ItemHeight = 15,
                        Location   = new Point(12, 12),
                        Size       = new Size(460, 94),
                        TabIndex   = 0,
                    };

                    var launchButton = new Button
                    {
                        Anchor   = AnchorStyles.Bottom | AnchorStyles.Right,
                        Location = new Point(397, 116),
                        Size     = new Size(75, 23),
                        TabIndex = 1,
                        Text     = "Launch",
                    };

                    var form = new Form
                    {
                        AcceptButton        = launchButton,
                        AutoScaleDimensions = new SizeF(7F, 15F),
                        AutoScaleMode       = AutoScaleMode.Font,
                        ClientSize          = new Size(484, 151),
                        Controls            = { listBox, launchButton },
                        KeyPreview          = true,
                        MinimumSize         = new Size(300, 150),
                        ShowIcon            = false,
                        StartPosition       = FormStartPosition.CenterScreen,
                        Text = c_appCaption,
                    };

                    foreach (var filePath in filePaths)
                    {
                        listBox.Items.Add(filePath);
                    }
                    listBox.SelectedIndex = 0;

                    listBox.MouseDoubleClick += (s, e) => LaunchSelectedFile();
                    launchButton.Click       += (s, e) => LaunchSelectedFile();
                    form.KeyDown             += (s, e) =>
                    {
                        if (e.KeyCode == Keys.Escape)
                        {
                            form.Close();
                        }
                    };

                    Application.Run(form);

                    void LaunchSelectedFile()
                    {
#pragma warning disable 8602 // https://github.com/dotnet/roslyn/issues/40821
                        LaunchFile(filePaths[listBox.SelectedIndex]);
                        form.Close();
#pragma warning restore 8602
                    }
                }
            }
        }
Exemple #21
0
        static void AutoGen()
        {
            var root = typeof(Program).Assembly.GetModules()[0].FullyQualifiedName;

            while (!File.Exists(Path.Combine(root, "NWayland.sln")))
            {
                root = Path.GetFullPath(Path.Combine(root, ".."));
                if (Path.GetPathRoot(root) == root)
                {
                    throw new InvalidOperationException("Unable to find base directory");
                }
            }

            string GetPath(params string[] elements) => Path.Combine(elements.Prepend(root).ToArray());

            IEnumerable <string> GlobPath(params string[] elements)
            {
                var subRoot = GetPath(elements.SkipLast(1).ToArray());
                var glob    = Glob.Files(subRoot, elements.Last());

                return(glob.Select(x => Path.Combine(subRoot, x)));
            }

            var coreProtocols = new List <string>();
            var kdeProtocols  = new List <string>();

            coreProtocols.Add(GetPath("external", "wayland", "protocol", "wayland.xml"));
            coreProtocols.AddRange(GlobPath("external", "wayland-protocols", "**/*.xml"));
            var hints = ProtocolHintsConfiguration.GetGeneratorHints();

            WaylandProtocolGroup Group(string assembly, string ns, IEnumerable <string> paths)
            => new WaylandProtocolGroup(assembly, ns)
            {
                Protocols = paths.Select(path =>
                                         (WaylandProtocol) new XmlSerializer(typeof(WaylandProtocol)).Deserialize(
                                             new StringReader(File.ReadAllText(path))))
                            .Where(p => !hints.ProtocolBlacklist.Contains(p.Name)).ToList()
            };

            var groups = new[]
            {
                Group("NWayland", "NWayland.Protocols", coreProtocols),
                Group("NWayland.Protocols.KWayland", "NWayland.Protocols.KWayland",
                      GlobPath("external", "kwayland", "src", "client", "protocols", "**/*.xml")),
                Group("NWayland.Protocols.Wlr", "NWayland.Protocols.Wlr",
                      GlobPath("external", "wlr-protocols", "**/*.xml"))
            };



            var gen = new WaylandProtocolGenerator(groups, hints);

            foreach (var g in groups)
            {
                var generatedDir = GetPath("src", g.Assembly, "Generated");
                if (Directory.Exists(generatedDir))
                {
                    Directory.Delete(generatedDir, true);
                }
                Directory.CreateDirectory(generatedDir);
                foreach (var protocol in g.Protocols)
                {
                    var generated = gen.Generate(protocol);
                    File.WriteAllText(Path.Combine(generatedDir, protocol.Name + ".generated.cs"), generated);
                }
            }
        }
        /// <summary>
        /// Loads source sprites referenced in declaration input and packs sprites into a sprite sheet.
        /// </summary>
        /// <param name="declaration">Sprite sheet delcaration input.</param>
        /// <param name="context">Context of the process routine.</param>
        /// <returns>Sprite sheet content.</returns>
        public override SpriteSheetContent Process(SpriteSheetDeclaration declaration, ContentProcessorContext context)
        {
            if (declaration == null)
            {
                throw new ArgumentNullException(nameof(declaration));
            }

            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            // Collect all texture file paths.
            //
            var texturePaths = new HashSet <string>();

            foreach (string pathPattern in declaration.PathPatterns)
            {
                foreach (string filePath in Glob.Files(Directory.GetCurrentDirectory(), pathPattern))
                {
                    texturePaths.Add(filePath);
                }
            }

            // Limit the packed texture based on the target graphics profile.
            //
            int maximumDimension = context.TargetProfile == GraphicsProfile.HiDef ? 4096 : 2048;

            PackedTexture packedTexture =
                SpritePacker.Pack(
                    configuration: new PackConfiguration(maximumDimension, maximumDimension, this.IsPowerOfTwo, this.IsSquare, this.Padding),
                    spritePaths: texturePaths.ToArray());

            // Ensure our output directory exists.
            //
            if (!Directory.Exists(context.OutputDirectory))
            {
                Directory.CreateDirectory(context.OutputDirectory);
            }

            // Write the packed texture to the output location.
            //
            string outputPath = Path.Combine(context.OutputDirectory, $"{declaration.Name}.png");

            using (var stream = new FileStream(outputPath, FileMode.Create))
            {
                packedTexture.Texture.Save(stream, ImageFormat.Png);
            }

            context.AddOutputFile(outputPath);

            // Finalize the content to serialize from this processor.
            //
            return(new SpriteSheetContent
            {
                Name = declaration.Name,
                SpriteNamesToIndexMapping = packedTexture.SpriteNamesToIndexMapping,
                SpriteRectangles = packedTexture.SpriteRectangles,
                Texture = this.BuildTexture($"{declaration.Name}Texture", outputPath, context),
            });
        }
Exemple #23
0
 private static IEnumerable <string> GetDirectoryFileList(string path)
 {
     return(Glob.Files(path, "**/*"));
 }
Exemple #24
0
        /// <summary>
        /// Gets all files matching glob pattern.
        /// See: https://github.com/kthompson/glob for supported pattern expressions and use cases.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="directory"></param>
        /// <param name="globPattern"></param>
        /// <returns></returns>
        public List <FileFullPath> GetFiles(GlobOptions globOptions = GlobOptions.None, params string[] globPattern)
        {
            var directoryInfo = new DirectoryInfo(_fullPath);

            return(globPattern.SelectMany(pattern => Glob.Files(directoryInfo, pattern, globOptions)).Select(x => new FileFullPath(x.FullName)).ToList());
        }
Exemple #25
0
 /// <summary>
 /// Finds the files matching the specified globs.
 /// </summary>
 /// <param name="directory">The starting directory.</param>
 /// <param name="globs">The globs to match.</param>
 /// <returns>The paths of the matching files.</returns>
 public static IReadOnlyList <string> FindFilesFrom(string directory, params string[] globs) =>
 globs.SelectMany(glob => Glob.Files(directory, glob, GlobOptions.CaseInsensitive)).Distinct().Select(path => Path.Combine(directory, path)).ToList();
        public void CreateGraphs(string path)
        {
            Console.WriteLine("Generating graphs...");
            // hour of day
            var f = new StreamWriter(path + "\\hour_of_day.plot");

            f.Write(GnuplotCommon);
            f.Write($@"
set output 'hour_of_day.{ImageType}'
unset key
set xrange [0.5:24.5]
set xtics 4
set grid y
set ylabel ""Commits""
plot 'hour_of_day.dat' using 1:2:(0.5) w boxes fs solid
");
            f.Close();
            // day of week
            f = new StreamWriter(path + "\\day_of_week.plot");
            f.Write(GnuplotCommon);
            f.Write($@"
set output 'day_of_week.{ImageType}'
unset key
set xrange [0.5:7.5]
set xtics 1
set grid y
set ylabel ""Commits""
plot 'day_of_week.dat' using 1:2:(0.5) w boxes fs solid
");
            f.Close();
            // Domains
            f = new StreamWriter(path + "\\domains.plot");
            f.Write(GnuplotCommon);
            f.Write($@"
set output 'domains.{ImageType}'
unset key
unset xtics
set grid y
set ylabel ""Commits""
plot 'domains.dat' using 2:3:(0.5) with boxes fs solid, '' using 2:3:1 with labels rotate by 45 offset 0,1
");
            f.Close();
            // Month of Year
            f = new StreamWriter(path + "\\month_of_year.plot");
            f.Write(GnuplotCommon);
            f.Write($@"
set output 'month_of_year.{ImageType}'
unset key
set xrange [0.5:12.5]
set xtics 1
set grid y
set ylabel ""Commits""
plot 'month_of_year.dat' using 1:2:(0.5) w boxes fs solid
");
            f.Close();
            // commits_by_year_month
            f = new StreamWriter(path + "\\commits_by_year_month.plot");
            f.Write(GnuplotCommon);
            f.Write($@"
set output 'commits_by_year_month.{ImageType}'
unset key
set xdata time
set timefmt ""%Y-%m""
set format x ""%Y-%m""
set xtics rotate by 90 15768000
set bmargin 5
set grid y
set ylabel ""Commits""
plot 'commits_by_year_month.dat' using 1:2:(0.5) w boxes fs solid
");
            f.Close();
            // commits_by_year
            f = new StreamWriter(path + "\\commits_by_year.plot");
            f.Write(GnuplotCommon);
            f.Write($@"
set output 'commits_by_year.{ImageType}'
unset key
set xtics 1 rotate by 90
set grid y
set ylabel ""Commits""
set yrange [0:]
plot 'commits_by_year.dat' using 1:2:(0.5) w boxes fs solid
");
            f.Close();
            // Files by date
            f = new StreamWriter(path + "\\files_by_date.plot");
            f.Write(GnuplotCommon);
            f.Write($@"
set output 'files_by_date.{ImageType}'
unset key
set xdata time
set timefmt ""%Y-%m-%d""
set format x ""%Y-%m-%d""
set grid y
set ylabel ""Files""
set xtics rotate by 90
set ytics autofreq
set bmargin 6
plot 'files_by_date.dat' using 1:2 w steps
");
            f.Close();
            // Lines of Code
            f = new StreamWriter(path + "\\lines_of_code.plot");
            f.Write(GnuplotCommon);
            f.Write($@"
set output 'lines_of_code.{ImageType}'
unset key
set xdata time
set timefmt ""%s""
set format x ""%Y-%m-%d""
set grid y
set ylabel ""Lines""
set xtics rotate by 90
set bmargin 6
plot 'lines_of_code.dat' using 1:2 w lines
");
            f.Close();
            Directory.SetCurrentDirectory(path);
            var matchingFiles = Glob.Files(path, "*.plot").ToArray();

            foreach (var file in matchingFiles)
            {
                var output = GitStats.GetPipeOutput(new[]
                {
                    Program.GnuPlotCmd + $" \"{file}\""
                });
                if (output.Length > 0)
                {
                    Console.WriteLine(output);
                }
            }
        }
Exemple #27
0
 public void PathTraversal()
 {
     var SourceRoot = Path.Combine("..", "..", "..", "..", "..");
     var results    = Glob.Files(SourceRoot, "test/*Tests/**/*.cs").ToList();
 }
Exemple #28
0
        public static IReadOnlyCollection <string> GlobFiles(string directory, params string[] patterns)
        {
            var directoryInfo = new DirectoryInfo(directory);

            return(patterns.SelectMany(x => Glob.Files(directoryInfo, x, GlobOptions)).Select(x => x.FullName).ToList());
        }