Exemplo n.º 1
0
        public static string PackageExtension(string extDirectory, string targetPath)
        {
            var dirInfo    = new DirectoryInfo(extDirectory);
            var extInfo    = ExtensionFactory.GetDescriptionFromFile(Path.Combine(extDirectory, PlaynitePaths.ExtensionManifestFileName));
            var packedPath = Path.Combine(targetPath, $"{dirInfo.Name}_{extInfo.Version.ToString().Replace(".", "_")}{PlaynitePaths.PackedExtensionFileExtention}");

            FileSystem.PrepareSaveFile(packedPath);
            var ignoreFiles = File.ReadAllLines(Paths.ExtFileIgnoreListPath);

            using (var zipStream = new FileStream(packedPath, FileMode.Create))
            {
                using (var zipFile = new ZipArchive(zipStream, ZipArchiveMode.Create))
                {
                    foreach (var file in Directory.GetFiles(extDirectory, "*.*", SearchOption.AllDirectories))
                    {
                        var subName = file.Replace(extDirectory, "").TrimStart(Path.DirectorySeparatorChar);
                        if (ignoreFiles.ContainsString(subName, StringComparison.OrdinalIgnoreCase))
                        {
                            continue;
                        }

                        zipFile.CreateEntryFromFile(file, subName);
                    }
                }
            }

            return(packedPath);
        }
Exemplo n.º 2
0
        public static ItemType GetExtensionType(string directory)
        {
            var themeMan = Path.Combine(directory, PlaynitePaths.ThemeManifestFileName);
            var extMan   = Path.Combine(directory, PlaynitePaths.ExtensionManifestFileName);

            if (File.Exists(themeMan))
            {
                var desc = ThemeManager.GetDescriptionFromFile(themeMan);
                switch (desc.Mode)
                {
                case ApplicationMode.Desktop:
                    return(ItemType.DesktopTheme);

                case ApplicationMode.Fullscreen:
                    return(ItemType.FullscreenTheme);
                }
            }
            else if (File.Exists(extMan))
            {
                var desc = ExtensionFactory.GetDescriptionFromFile(extMan);
                switch (desc.Type)
                {
                case ExtensionType.GenericPlugin:
                    return(ItemType.GenericPlugin);

                case ExtensionType.GameLibrary:
                    return(ItemType.LibraryPlugin);

                case ExtensionType.Script:
                    return(desc.Module.EndsWith("ps1", StringComparison.OrdinalIgnoreCase) ? ItemType.PowerShellScript : ItemType.IronPythonScript);

                case ExtensionType.MetadataProvider:
                    return(ItemType.MetadataPlugin);
                }
            }

            return(ItemType.Uknown);
        }