Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 66 additions & 3 deletions GenHub/GenHub.Core/Constants/CatalogConstants.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
namespace GenHub.Core.Constants;

/// <summary>
/// Constants for publisher catalog system.
/// Constants for the modular publisher-catalog system.
/// </summary>
/// <remarks>
/// Layering (see Publisher Studio architecture):
/// <list type="bullet">
/// <item>
/// <b>Provider Definition</b> — static publisher metadata + catalog endpoint(s)
/// (bundled <c>*.provider.json</c> today; user-hosted definitions via Publisher Studio later).
/// </item>
/// <item>
/// <b>Catalog</b> — dynamic content listing (<c>catalog.json</c> / remote endpoint), updated on each release.
/// </item>
/// <item>
/// <b>Artifacts</b> — downloadable files referenced by catalog releases.
/// </item>
/// </list>
/// Anyone can author a GenHub-schema catalog, host it, and share
/// <c>genhub://subscribe?url=...</c>. Discovery uses <see cref="GenericCatalogResolverId"/>
/// for catalog-direct subscriptions without per-publisher code.
/// </remarks>
public static class CatalogConstants
{
/// <summary>
Expand All @@ -11,12 +29,17 @@ public static class CatalogConstants
public const int CatalogSchemaVersion = 1;

/// <summary>
/// Filename for subscriptions storage.
/// Filename for user subscription storage under application data.
/// </summary>
public const string SubscriptionFileName = "subscriptions.json";

/// <summary>
/// Resolver ID for generic catalog resolver.
/// Sidebar / discoverer category for user-subscribed catalogs (vs built-in static/dynamic).
/// </summary>
public const string SubscribedPublisherCategory = "subscribed";
Comment thread
undead2146 marked this conversation as resolved.

/// <summary>
/// Resolver / pipeline ID for the generic catalog pipeline (any GenHub-schema catalog).
/// </summary>
public const string GenericCatalogResolverId = "generic-catalog";

Expand All @@ -29,4 +52,44 @@ public static class CatalogConstants
/// Maximum catalog size in bytes (10 MB).
/// </summary>
public const long MaxCatalogSizeBytes = 10 * 1024 * 1024;

/// <summary>
/// Maximum number of entries allowed when extracting publisher catalog archives.
/// </summary>
public const int MaxZipEntryCount = 50_000;

/// <summary>
/// Maximum cumulative uncompressed size allowed when extracting publisher catalog archives (5 GB).
/// </summary>
public const long MaxZipUncompressedSizeBytes = 5L * 1024 * 1024 * 1024;
Comment thread
undead2146 marked this conversation as resolved.

/// <summary>
/// Resolver metadata key for serialized publisher profile JSON.
/// </summary>
public const string PublisherProfileJsonMetadataKey = "publisherProfileJson";

/// <summary>
/// Resolver metadata key for serialized catalog item JSON.
/// </summary>
public const string CatalogItemJsonMetadataKey = "catalogItemJson";

/// <summary>
/// Resolver metadata key for serialized release JSON.
/// </summary>
public const string ReleaseJsonMetadataKey = "releaseJson";

/// <summary>
/// Resolver metadata key for the stable catalog content id (not the display name).
/// </summary>
public const string CatalogContentIdMetadataKey = "catalogContentId";

/// <summary>
/// Resolver metadata key for serialized bundle component descriptors.
/// </summary>
public const string BundleComponentsJsonMetadataKey = "bundleComponentsJson";

/// <summary>
/// Resolver metadata key for serialized publisher referrals JSON.
/// </summary>
public const string CatalogReferralsJsonMetadataKey = "catalogReferralsJson";
}
191 changes: 191 additions & 0 deletions GenHub/GenHub.Core/Constants/GameContentConstants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace GenHub.Core.Constants;

/// <summary>
/// Constants for game content structure, archive payload normalization, and recognized game assets.
/// </summary>
public static class GameContentConstants
{
/// <summary>
/// Maximum recursive wrapper directory stripping depth.
/// </summary>
public const int MaxWrapperNormalizationDepth = 10;

/// <summary>
/// Supported archive file extensions.
/// </summary>
public static readonly IReadOnlyList<string> ArchiveExtensions =
Comment thread
undead2146 marked this conversation as resolved.
[
".zip",
".7z",
".rar",
".dat",
];
Comment thread
undead2146 marked this conversation as resolved.

/// <summary>
/// Canonical directory names used at the game workspace root.
/// </summary>
public static readonly IReadOnlyList<string> RecognizedGameDirectories =
[
"Data",
"Art",
"Window",
"Audio",
"Maps",
"INI",
"Scripts",
"Textures",
"W3D",
"English",
"German",
"French",
"Italian",
"Spanish",
"Korean",
"Polish",
"Chinese",
];

/// <summary>
/// Canonical file extensions for game assets, binaries, and configurations.
/// </summary>
public static readonly IReadOnlyList<string> RecognizedGameFileExtensions =
[
".big",
".exe",
".dll",
".str",
".csf",
".ini",
".map",
".bik",
".asi",
];

/// <summary>
/// Extensions for loose non-game documentation and metadata files.
/// </summary>
public static readonly IReadOnlyList<string> DocumentationExtensions =
[
".txt",
".url",
".md",
".htm",
".html",
".pdf",
".lnk",
".jpg",
".jpeg",
".png",
".gif",
".bmp",
];

/// <summary>
/// System junk file or directory names to purge during payload normalization.
/// </summary>
public static readonly IReadOnlyList<string> SystemJunkNames =
[
".ds_store",
"thumbs.db",
"desktop.ini",
"__macosx",
];

/// <summary>
/// Subfolder aliases that denote Zero Hour specific game content.
/// </summary>
public static readonly IReadOnlyList<string> ZeroHourSubfolderAliases =
[
"Zero Hour",
"ZH",
"Command and Conquer Generals Zero Hour",
"Command & Conquer Generals - Zero Hour",
"Command & Conquer: Generals - Zero Hour",
"C&C Generals Zero Hour",
"ZeroHour",
];

/// <summary>
/// Subfolder aliases that denote Generals specific game content.
/// </summary>
public static readonly IReadOnlyList<string> GeneralsSubfolderAliases =
[
"Generals",
"CCG",
"Command and Conquer Generals",
"Command & Conquer Generals",
"C&C Generals",
];

/// <summary>
/// Default variant resolution for control bar packages.
/// </summary>
public const string DefaultControlBarVariant = "1080p";

Check warning on line 128 in GenHub/GenHub.Core/Constants/GameContentConstants.cs

View workflow job for this annotation

GitHub Actions / Build macOS

Constant fields should appear before non-constant fields (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1203.md)

Check warning on line 128 in GenHub/GenHub.Core/Constants/GameContentConstants.cs

View workflow job for this annotation

GitHub Actions / Build macOS

Constant fields should appear before non-constant fields (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1203.md)

Check warning on line 128 in GenHub/GenHub.Core/Constants/GameContentConstants.cs

View workflow job for this annotation

GitHub Actions / Build macOS

Constant fields should appear before non-constant fields (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1203.md)

Check warning on line 128 in GenHub/GenHub.Core/Constants/GameContentConstants.cs

View workflow job for this annotation

GitHub Actions / Build Linux

Constant fields should appear before non-constant fields (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1203.md)

Check warning on line 128 in GenHub/GenHub.Core/Constants/GameContentConstants.cs

View workflow job for this annotation

GitHub Actions / Build Linux

Constant fields should appear before non-constant fields (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1203.md)

Check warning on line 128 in GenHub/GenHub.Core/Constants/GameContentConstants.cs

View workflow job for this annotation

GitHub Actions / Build Windows

Constant fields should appear before non-constant fields (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1203.md)

Check warning on line 128 in GenHub/GenHub.Core/Constants/GameContentConstants.cs

View workflow job for this annotation

GitHub Actions / Build Windows

Constant fields should appear before non-constant fields (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1203.md)

Check warning on line 128 in GenHub/GenHub.Core/Constants/GameContentConstants.cs

View workflow job for this annotation

GitHub Actions / Build Windows

Constant fields should appear before non-constant fields (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1203.md)

Check warning on line 128 in GenHub/GenHub.Core/Constants/GameContentConstants.cs

View workflow job for this annotation

GitHub Actions / Build Windows

Constant fields should appear before non-constant fields (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1203.md)

Check warning on line 128 in GenHub/GenHub.Core/Constants/GameContentConstants.cs

View workflow job for this annotation

GitHub Actions / Build Windows

Constant fields should appear before non-constant fields (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1203.md)

/// <summary>
/// Base filename for standard Control Bar Pro BIG archive.
/// </summary>
public const string ControlBarProBaseFileName = "340_ControlBarProZH.big";

/// <summary>
/// Base filename for Lemon Edition Control Bar Pro BIG archive.
/// </summary>
public const string ControlBarProLemonBaseFileName = "340_ControlBarProLemonEditionZH.big";

/// <summary>
/// Standard subfolder name for English BIG files.
/// </summary>
public const string BigEnDirectoryName = "BIG EN";

/// <summary>
/// Standard subfolder name for BIG files.
/// </summary>
public const string BigDirectoryName = "BIG";

/// <summary>
/// GenTool directory name.
/// </summary>
public const string GenToolDirectoryName = "GenTool";

/// <summary>
/// Window directory name.
/// </summary>
public const string WindowDirectoryName = "Window";

/// <summary>
/// Determines whether the specified directory name is a recognized canonical game directory.
/// </summary>
/// <param name="directoryName">The directory name to check.</param>
/// <returns><c>true</c> if recognized; otherwise, <c>false</c>.</returns>
public static bool IsRecognizedGameDirectory(string? directoryName)
{
return !string.IsNullOrEmpty(directoryName) &&
RecognizedGameDirectories.Contains(directoryName, StringComparer.OrdinalIgnoreCase);
}

/// <summary>
/// Determines whether the specified file extension or file name represents a recognized game asset.
/// </summary>
/// <param name="fileNameOrExtension">The file name or extension to check.</param>
/// <returns><c>true</c> if recognized; otherwise, <c>false</c>.</returns>
public static bool IsRecognizedGameFile(string? fileNameOrExtension)
{
if (string.IsNullOrEmpty(fileNameOrExtension))
{
return false;
}

var ext = Path.GetExtension(fileNameOrExtension);
if (string.IsNullOrEmpty(ext))
{
ext = fileNameOrExtension;
Comment thread
undead2146 marked this conversation as resolved.
}

return RecognizedGameFileExtensions.Contains(ext, StringComparer.OrdinalIgnoreCase);
}
Comment thread
undead2146 marked this conversation as resolved.
}
5 changes: 5 additions & 0 deletions GenHub/GenHub.Core/Constants/IoConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ public static class IoConstants
/// </summary>
public const int DefaultFileBufferSize = 4096;

/// <summary>
/// Buffer size used when scanning binary streams for embedded signatures (8KB).
/// </summary>
public const int SignatureScanBufferSize = 8192;

/// <summary>
/// How many times a path may be re-resolved while following symbolic links whose targets are
/// themselves reached through links. Bounds the walk on a filesystem that contains a cycle.
Expand Down
Loading
Loading