Exemple #1
0
        public object Clone()
        {
            var newObject = new DesktopFile
            {
                Exec             = string.Copy(exec),
                profilePath      = string.Copy(profilePath),
                name             = string.Copy(name),
                cePrefix         = string.Copy(cePrefix),
                iconPath         = string.Copy(iconPath),
                iconFilename     = string.Copy(iconFilename),
                code             = string.Copy(code),
                testId           = testId,
                status           = string.Copy(status),
                players          = players,
                simultaneous     = simultaneous,
                releaseDate      = string.Copy(releaseDate),
                saveCount        = saveCount,
                sortRawTitle     = string.Copy(sortRawTitle),
                sortRawPublisher = string.Copy(sortRawPublisher),
                copyright        = string.Copy(copyright),
                description      = string.Copy(description),
                genre            = string.Copy(genre),
                index            = string.Copy(index),
                demoTime         = string.Copy(demoTime),
                country          = string.Copy(country),
                regionTag        = string.Copy(regionTag)
            };

            return(newObject);
        }
Exemple #2
0
        private void ShowCommand()
        {
            var items = listViewGames.SelectedItems;

            if (items.Count == 0 || listBoxCore.SelectedItem == null)
            {
                commandTextBox.Text    = string.Empty;
                commandTextBox.Enabled = false;
                return;
            }

            var core = listBoxCore.SelectedItem as CoreCollection.CoreInfo;

            if (items.Count > 1)
            {
                string newCommand = core.QualifiedBin + " {rom}";
                if (resetCheckBox.Checked)
                {
                    newCommand += string.IsNullOrEmpty(core.DefaultArgs) ? string.Empty : (" " + core.DefaultArgs);
                }
                else
                {
                    newCommand += " {args}";
                }

                commandTextBox.Text    = newCommand.Trim();
                commandTextBox.Enabled = true;
            }
            else if (items.Count == 1)
            {
                var item = items[0];
                var game = item.Tag as NesApplication;
                if (resetCheckBox.Checked)
                {
                    string newCommand = core.QualifiedBin;
                    if (game.Desktop.Args.Length > 0)
                    {
                        newCommand += " " + game.Desktop.Args[0];
                    }
                    newCommand         += " " + core.DefaultArgs;
                    commandTextBox.Text = newCommand.Trim();
                }
                else
                {
                    DesktopFile desktop = (DesktopFile)game.Desktop.Clone();
                    desktop.Bin         = core.QualifiedBin;
                    commandTextBox.Text = desktop.Exec.Trim();
                }
                commandTextBox.Enabled = true;
            }
            buttonApply.Enabled = true;
        }
Exemple #3
0
        public object Clone()
        {
            var newObject = new DesktopFile
            {
                Exec             = string.Copy(exec),
                profilePath      = string.Copy(profilePath),
                name             = string.Copy(name),
                iconPath         = string.Copy(iconPath),
                iconFilename     = string.Copy(iconFilename),
                code             = string.Copy(code),
                testId           = testId,
                status           = string.Copy(status),
                players          = players,
                simultaneous     = simultaneous,
                releaseDate      = string.Copy(releaseDate),
                saveCount        = saveCount,
                sortRawTitle     = string.Copy(sortRawTitle),
                sortRawPublisher = string.Copy(sortRawPublisher),
                copyright        = string.Copy(copyright)
            };

            return(newObject);
        }
        public static TaskFunc FindGamesTask(Dictionary <String, FoundGame> foundGames)
        {
            return((Tasker tasker, Object taskObject) =>
            {
                tasker.SetStatus(Resources.Scanning);
                if (hakchi.Shell.IsOnline)
                {
                    var mountpoint = hakchi.Shell is ClovershellConnection ? "" : hakchi.Shell.ExecuteSimple("hakchi get mountpoint", throwOnNonZero: true);
                    var rootfs = hakchi.Shell is ClovershellConnection ? "/var/lib/hakchi/rootfs" : hakchi.Shell.ExecuteSimple("hakchi get rootfs", throwOnNonZero: true);
                    var searchPaths = new string[]
                    {
                        $"{rootfs}/usr/share/games",
                        $"{mountpoint}/var/lib/hakchi/games",
                        $"{mountpoint}/media/hakchi/games"
                    };
                    using (var desktopTarStream = new MemoryStream())
                        using (var sizeStream = new MemoryStream())
                        {
                            var paths = "";
                            foreach (var path in searchPaths)
                            {
                                paths = $"{paths} {Shared.EscapeShellArgument(path)}";
                            }

                            hakchi.Shell.Execute($"find {paths} -name \"CLV-*.desktop\" | sort | tar -cf - -T -", null, desktopTarStream);
                            desktopTarStream.Seek(0, SeekOrigin.Begin);

                            var sizeRegex = new Regex(@"^(\d+)\s*(/.*)$", RegexOptions.Multiline);
                            if (desktopTarStream.Length > 0)
                            {
                                hakchi.Shell.Execute($"du {paths}", null, sizeStream);
                                sizeStream.Seek(0, SeekOrigin.Begin);

                                using (var extractor = ArchiveFactory.Open(desktopTarStream))
                                    using (var reader = extractor.ExtractAllEntries())
                                    {
                                        while (reader.MoveToNextEntry())
                                        {
                                            var entry = reader.Entry;
                                            Trace.WriteLine(entry.Key);
                                            using (var entryStream = reader.OpenEntryStream())
                                            {
                                                var key = Path.GetDirectoryName($"/{entry.Key}").Replace('\\', '/');
                                                var desktop = new DesktopFile(entryStream);

                                                if (desktop.IconPath.EndsWith("/.storage"))
                                                {
                                                    // This is a linked game
                                                    key = $"{mountpoint}{desktop.IconPath}/{desktop.Code}";
                                                }

                                                desktop.Exec = desktop.Exec.Replace(desktop.IconPath, "/var/games");
                                                desktop.IconPath = "/var/games";
                                                desktop.ProfilePath = "/var/saves";

                                                if (!NesApplication.AllDefaultGames.ContainsKey(desktop.Code) && desktop.Bin != "/bin/chmenu")
                                                {
                                                    foundGames.Add(key, new FoundGame()
                                                    {
                                                        RemotePath = key,
                                                        Desktop = desktop,
                                                        Size = 0
                                                    });
                                                }
                                            }
                                        }
                                    }

                                using (var sr = new StreamReader(sizeStream))
                                {
                                    var matches = sizeRegex.Matches(sr.ReadToEnd());
                                    foreach (Match match in matches)
                                    {
                                        var size = long.Parse(match.Groups[1].Value) * 1024;
                                        var path = match.Groups[2].Value;
                                        if (foundGames.ContainsKey(path))
                                        {
                                            foundGames[path].Size = size;
                                        }
                                    }
                                }
                            }
                        }
                    return Conclusion.Success;
                }
                return Conclusion.Error;
            });
        }