From ebfca0fbb9a464d4ed4d21ce052c5975166c47b3 Mon Sep 17 00:00:00 2001 From: Tony Bark Date: Wed, 30 Apr 2025 07:28:39 -0400 Subject: [PATCH 01/11] Makefile --- .gitignore | 1 + Makefile | 26 ++++++++++++++++++++++++++ README.md | 8 ++++---- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index f30c023..cad8fe1 100644 --- a/.gitignore +++ b/.gitignore @@ -546,3 +546,4 @@ FodyWeavers.xsd .idea/** *.s2pk s2pk.toml +dist/** diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f3f883a --- /dev/null +++ b/Makefile @@ -0,0 +1,26 @@ +# Makefile for building and packaging the Sims 2 .s2pk CLI tool + +APP_NAME = s2pk +CONFIGURATION = Release +RUNTIME_LINUX = linux-x64 +RUNTIME_MAC = osx-x64 +OUTPUT_DIR = ./dist + +.PHONY: all clean build-linux build-mac package-linux package-mac + +all: build-linux build-mac package-linux package-mac + +clean: + rm -rf bin obj $(OUTPUT_DIR) + +build-linux: + dotnet publish -c $(CONFIGURATION) -r $(RUNTIME_LINUX) --self-contained true /p:PublishSingleFile=true -o $(OUTPUT_DIR)/$(APP_NAME)-linux + +build-mac: + dotnet publish -c $(CONFIGURATION) -r $(RUNTIME_MAC) --self-contained true /p:PublishSingleFile=true -o $(OUTPUT_DIR)/$(APP_NAME)-mac + +package-linux: + tar -czvf $(OUTPUT_DIR)/$(APP_NAME)-linux.tar.gz -C $(OUTPUT_DIR)/$(APP_NAME)-linux . + +package-mac: + tar -czvf $(OUTPUT_DIR)/$(APP_NAME)-mac.tar.gz -C $(OUTPUT_DIR)/$(APP_NAME)-mac . diff --git a/README.md b/README.md index acb2f45..14f7030 100644 --- a/README.md +++ b/README.md @@ -33,10 +33,10 @@ s2pk unpack -p ./output.s2pk -d "%USERPROFILE%\Documents\EA Games\The Sims 2\Dow ## πŸ—“οΈ Update Cycle -| Type | Frequency | Notes | -| ------------ | ---------------- | ---------------------------------------- | -| Minor Update | Every 3–6 months | Small enhancements, non-breaking changes | -| Patch Update | As needed | Bug fixes, security updates | +| Type | Frequency | Notes | +| ---------------- | ---------------- | ---------------------------------------- | +| Minor Update | Every 3–6 months | Small enhancements, non-breaking changes | +| Patch Update | As needed | Bug fixes, security updates | | Major Update[^1] | As needed | Framework upgrades, major refactors | - Reserve months: June (Mid-Year Chill) & December (End-Year Freeze) From 170a46b6bf8b713918018c8c616541e35683c88b Mon Sep 17 00:00:00 2001 From: Tony Bark Date: Wed, 30 Apr 2025 07:36:42 -0400 Subject: [PATCH 02/11] Updated roadmap - Removed footnotes due to rendering issue --- README.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 14f7030..91afc5d 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,9 @@ S2PK was created to address the need for a reliable and efficient cross-platform | Phase | Goal | Status | | ----- | ------------------------------------------- | ------ | -| v0.1 | Core package manager | βœ… | +| v0.1 | Core package manager | βœ… | | v0.2 | Config file with default destination | πŸ”œ | +| v0.x | Target .NET 10 | πŸ”œ | | v1.0 | Stable "Release" version with documentation | πŸ”œ | ## 🧩 Tech Stack @@ -33,11 +34,11 @@ s2pk unpack -p ./output.s2pk -d "%USERPROFILE%\Documents\EA Games\The Sims 2\Dow ## πŸ—“οΈ Update Cycle -| Type | Frequency | Notes | -| ---------------- | ---------------- | ---------------------------------------- | -| Minor Update | Every 3–6 months | Small enhancements, non-breaking changes | -| Patch Update | As needed | Bug fixes, security updates | -| Major Update[^1] | As needed | Framework upgrades, major refactors | +| Type | Frequency | Notes | +| ------------ | ---------------- | ---------------------------------------- | +| Minor Update | Every 3–6 months | Small enhancements, non-breaking changes | +| Patch Update | As needed | Bug fixes, security updates | +| Major Update | As needed | Framework upgrades, major refactors | - Reserve months: June (Mid-Year Chill) & December (End-Year Freeze) @@ -56,10 +57,6 @@ s2pk unpack -p ./output.s2pk -d "%USERPROFILE%\Documents\EA Games\The Sims 2\Dow - Critical vulnerabilities - Framework-breaking issues -## πŸ” Footnotes - -- [^1]: At this early stage, major updates bump the minor version number. This usually involves re-targeting to the newest .NET LTS. - ## πŸ—’οΈ License I license this project under the GPL v3 license - see [LICENSE](LICENSE) for details. From b23431cdb2b6b2037b5ec78001724ad77596d304 Mon Sep 17 00:00:00 2001 From: Tony Bark Date: Wed, 30 Apr 2025 08:46:02 -0400 Subject: [PATCH 03/11] Fallback to config for destination directory - Install script - Rewrote Why This Exists section - Method documentation comments --- Config.cs | 18 ++++++++++++++++++ GlobalUsing.cs | 2 ++ PackageManger.cs | 20 ++++++++++++++++++-- Program.cs | 4 +--- README.md | 36 ++++++++++++++++++++++++++++++++---- S2PK.csproj | 2 +- install.sh | 27 +++++++++++++++++++++++++++ 7 files changed, 99 insertions(+), 10 deletions(-) create mode 100644 Config.cs create mode 100644 GlobalUsing.cs create mode 100644 install.sh diff --git a/Config.cs b/Config.cs new file mode 100644 index 0000000..c1c5435 --- /dev/null +++ b/Config.cs @@ -0,0 +1,18 @@ +namespace S2PK; + +public class Config +{ + public string Destination { get; set; } = string.Empty; + + /// + /// Loads the configuration from the specified file path. + /// + /// The path to the configuration file. + /// The loaded configuration. + public static Config Load(string path) + { + var file = File.ReadAllText(path); + var config = Toml.ToModel(file); + return config; + } +} diff --git a/GlobalUsing.cs b/GlobalUsing.cs new file mode 100644 index 0000000..800695e --- /dev/null +++ b/GlobalUsing.cs @@ -0,0 +1,2 @@ +global using S2PK; +global using Tomlyn; diff --git a/PackageManger.cs b/PackageManger.cs index 38d2ab5..bd44614 100644 --- a/PackageManger.cs +++ b/PackageManger.cs @@ -1,4 +1,4 @@ -namespace S2Pkg; +namespace S2PK; using System.IO.Compression; @@ -7,6 +7,11 @@ public static class PackageManager const string PackageExtension = ".package"; const string S2pkExtension = ".s2pk"; + /// + /// Packs a directory into a package file. + /// + /// The source directory. + /// The output package file. public static void PackPackages(string source, string output) { var dir = new DirectoryInfo(source); @@ -36,8 +41,19 @@ public static class PackageManager Console.WriteLine($"Created {file.FullName} with {packageFiles.Length} files."); } - public static void UnpackPackages(string package, string destination) + /// + /// Unpacks a package file into a destination directory. + /// + /// The path to the package file. + /// The destination directory. If not provided, the destination is read from the configuration file. + public static void UnpackPackages(string package, string destination = "") { + if (string.IsNullOrEmpty(destination)) + { + var config = Config.Load("s2pk.toml"); // TODO: Config file should be in application directory + destination = config.Destination; + } + var file = new FileInfo(package); var dir = new DirectoryInfo(destination); diff --git a/Program.cs b/Program.cs index 307e2e7..ba595e0 100644 --- a/Program.cs +++ b/Program.cs @@ -1,4 +1,3 @@ -using S2Pkg; using System.CommandLine; var rootCommand = new RootCommand("The Sims 2 .s2pk Package Manager"); @@ -32,8 +31,7 @@ var packageOption = new Option( var destinationOption = new Option( aliases: ["--destination", "-d"], - description: "Destination directory (e.g., The Sims 2 Downloads folder)") -{ IsRequired = true }; + description: "Destination directory (e.g., The Sims 2 Downloads folder)"); // Unpack command var unpackCommand = new Command("unpack", "Unpacks a .s2pk archive to the Downloads folder") diff --git a/README.md b/README.md index 91afc5d..283c864 100644 --- a/README.md +++ b/README.md @@ -2,19 +2,26 @@ S2PK, or Sims 2 Package Manager, aims to provide a simple cross-platform solution to package management. -## πŸ’‘ Why This Exists +## ❓ Why This Exists -S2PK was created to address the need for a reliable and efficient cross-platform package management system for The Sims 2 on Linux and macOS. Players on these platforms often face challenges in managing mods due to the lack of a unified solution that their Windows counterparts solved a long time ago. +While The Sims 2 runs well on Linux through Wine, especially with Lutris setups, and natively from macOS, only the Windows community had varies mod managers and installers compared to their cross-platform counterparts. Later installments addressed this dilemma, but TS2 never got that treatment. + +``s2pk`` aims to fill this gap: a no-nonsense CLI utility for packaging, sharing, and managing mods across all platforms. It’s small, clean, and plays nicely with scripts, backups, and version control. In theory, it would be possible to use it on legacy front ends. ## πŸ›£οΈ Project Roadmap | Phase | Goal | Status | | ----- | ------------------------------------------- | ------ | -| v0.1 | Core package manager | βœ… | +| v0.1 | Core package manager | βœ… | | v0.2 | Config file with default destination | πŸ”œ | | v0.x | Target .NET 10 | πŸ”œ | | v1.0 | Stable "Release" version with documentation | πŸ”œ | +## 🎯 Stretch Goals + +- [ ] Manifest validation +- [ ] ``s1pk`` soft fork + ## 🧩 Tech Stack - .NET 8.0 @@ -22,7 +29,28 @@ S2PK was created to address the need for a reliable and efficient cross-platform - System.CommandLine for CLI parsing (no external libraries) - Pure backend logic (no UI planned) -## Example +## πŸ“ Design Principles + +- Stay true to UNIX design philosophy +- Simple with no bloat or feature creep +- Portable and clean + +## πŸ› οΈ Installation + +You can build yourself with ``make``, or use the installer script: + +```shell +./install.sh ./dist/s2pk-linux/s2pkg +``` + +Make sure ``~/.local/bin`` is in your ``PATH``: + +```shell +echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc +source ~/.bashrc +``` + +## πŸ—œοΈ Usage ```shell s2pk pack -s ./mods -o output.s2pk diff --git a/S2PK.csproj b/S2PK.csproj index 48a4c19..e970283 100644 --- a/S2PK.csproj +++ b/S2PK.csproj @@ -13,8 +13,8 @@ - + diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..20a5fda --- /dev/null +++ b/install.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Install s2pkg locally for current user (no sudo) +# Usage: ./install.sh ./dist/s2pkg-linux/s2pkg + +set -e + +SOURCE_BIN="$1" +INSTALL_DIR="$HOME/.local/bin" +TARGET="$INSTALL_DIR/s2pkg" + +if [[ ! -x "$SOURCE_BIN" ]]; then + echo "❌ Error: Provide a valid built s2pkg binary as the first argument." + exit 1 +fi + +mkdir -p "$INSTALL_DIR" +cp "$SOURCE_BIN" "$TARGET" +chmod +x "$TARGET" + +if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then + echo "⚠️ $INSTALL_DIR is not in your PATH. Consider adding this to your shell profile:" + echo " export PATH=\"\$HOME/.local/bin:\$PATH\"" +else + echo "βœ… Installed s2pkg to $TARGET" + echo "Run 's2pkg --help' to get started." +fi From 8d07e6d307d908b5b97d4e7f0670452770cdf047 Mon Sep 17 00:00:00 2001 From: Tony Bark Date: Wed, 30 Apr 2025 08:52:43 -0400 Subject: [PATCH 04/11] Tweaked config location TODO --- PackageManger.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PackageManger.cs b/PackageManger.cs index bd44614..81e5fa8 100644 --- a/PackageManger.cs +++ b/PackageManger.cs @@ -50,7 +50,7 @@ public static class PackageManager { if (string.IsNullOrEmpty(destination)) { - var config = Config.Load("s2pk.toml"); // TODO: Config file should be in application directory + var config = Config.Load("s2pk.toml"); // TODO: Config file should be in home directory destination = config.Destination; } From 7af7fc427b9aca54ed13c542f6759df6469aaed0 Mon Sep 17 00:00:00 2001 From: Tony Bark Date: Wed, 30 Apr 2025 09:04:18 -0400 Subject: [PATCH 05/11] Support for The Sims 3 in config file --- Config.cs | 8 +++++++- PackageManger.cs | 11 +++++++++-- s2pk.toml.sample | 4 +++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Config.cs b/Config.cs index c1c5435..74a65e4 100644 --- a/Config.cs +++ b/Config.cs @@ -2,7 +2,7 @@ namespace S2PK; public class Config { - public string Destination { get; set; } = string.Empty; + public Destination Games { get; set; } = new(); /// /// Loads the configuration from the specified file path. @@ -16,3 +16,9 @@ public class Config return config; } } + +public class Destination +{ + public string Sims2 { get; set; } = string.Empty; + public string Sims3 { get; set; } = string.Empty; +} diff --git a/PackageManger.cs b/PackageManger.cs index 81e5fa8..5ef93f3 100644 --- a/PackageManger.cs +++ b/PackageManger.cs @@ -46,12 +46,19 @@ public static class PackageManager /// /// The path to the package file. /// The destination directory. If not provided, the destination is read from the configuration file. - public static void UnpackPackages(string package, string destination = "") + /// Whether to unpack for The Sims 3. + public static void UnpackPackages(string package, string destination = "", bool ts3 = false) { + // If destination is not provided, read from configuration file if (string.IsNullOrEmpty(destination)) { var config = Config.Load("s2pk.toml"); // TODO: Config file should be in home directory - destination = config.Destination; + + // If The Sims 3 is not specified, use the default destination + if (!ts3) + destination = config.Games.Sims2; + else + destination = config.Games.Sims3; } var file = new FileInfo(package); diff --git a/s2pk.toml.sample b/s2pk.toml.sample index 5f2bf08..950c7a2 100644 --- a/s2pk.toml.sample +++ b/s2pk.toml.sample @@ -1 +1,3 @@ -destination ≑ "path/to/destination" +[games] +sims2 ≑ "path/to/sims2" +sims3 ≑ "path/to/sims3" From f65698fcb62311c11b2ba81b7cea227153d7f23f Mon Sep 17 00:00:00 2001 From: Tony Bark Date: Wed, 30 Apr 2025 09:14:07 -0400 Subject: [PATCH 06/11] Renamed games option to paths --- Config.cs | 6 +++--- s2pk.toml.sample | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Config.cs b/Config.cs index 74a65e4..b896468 100644 --- a/Config.cs +++ b/Config.cs @@ -2,7 +2,7 @@ namespace S2PK; public class Config { - public Destination Games { get; set; } = new(); + public Destinations Paths { get; set; } = new(); /// /// Loads the configuration from the specified file path. @@ -13,11 +13,11 @@ public class Config { var file = File.ReadAllText(path); var config = Toml.ToModel(file); - return config; + return config ?? throw new FileNotFoundException("Configuration file not found."); } } -public class Destination +public class Destinations { public string Sims2 { get; set; } = string.Empty; public string Sims3 { get; set; } = string.Empty; diff --git a/s2pk.toml.sample b/s2pk.toml.sample index 950c7a2..3399cb5 100644 --- a/s2pk.toml.sample +++ b/s2pk.toml.sample @@ -1,3 +1,3 @@ -[games] +[paths] sims2 ≑ "path/to/sims2" sims3 ≑ "path/to/sims3" From 18a0e73a91e116f61cded74099e3e088e70f9c52 Mon Sep 17 00:00:00 2001 From: Tony Bark Date: Wed, 30 Apr 2025 09:23:25 -0400 Subject: [PATCH 07/11] Bump to v0.2 - Preemptive support for s3pk extensions --- PackageManger.cs | 6 ++++-- README.md | 6 ++++++ S2PK.csproj | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/PackageManger.cs b/PackageManger.cs index 5ef93f3..f22dfdc 100644 --- a/PackageManger.cs +++ b/PackageManger.cs @@ -6,6 +6,7 @@ public static class PackageManager { const string PackageExtension = ".package"; const string S2pkExtension = ".s2pk"; + const string S3pkExtension = ".s3pk"; /// /// Packs a directory into a package file. @@ -16,6 +17,7 @@ public static class PackageManager { var dir = new DirectoryInfo(source); var file = new FileInfo(output); + var extention = S2pkExtension; if (!dir.Exists) { @@ -56,9 +58,9 @@ public static class PackageManager // If The Sims 3 is not specified, use the default destination if (!ts3) - destination = config.Games.Sims2; + destination = config.Paths.Sims2; else - destination = config.Games.Sims3; + destination = config.Paths.Sims3; } var file = new FileInfo(package); diff --git a/README.md b/README.md index 283c864..8b3568f 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,12 @@ While The Sims 2 runs well on Linux through Wine, especially with Lutris setups, ``s2pk`` aims to fill this gap: a no-nonsense CLI utility for packaging, sharing, and managing mods across all platforms. It’s small, clean, and plays nicely with scripts, backups, and version control. In theory, it would be possible to use it on legacy front ends. +## πŸš€ Features + +- First-class CLI support for modders on non-Windows platforms +- Custom default unpacking directory for The Sims 2 & 3 +- Pack ``.packages`` into portable ``.s2pk`` archives + ## πŸ›£οΈ Project Roadmap | Phase | Goal | Status | diff --git a/S2PK.csproj b/S2PK.csproj index e970283..4747aeb 100644 --- a/S2PK.csproj +++ b/S2PK.csproj @@ -3,7 +3,7 @@ Exe net8.0 - 0.1.101 + 0.2.101 enable enable Tony Bark From b060f1de5e7bd5596055e4036c7c63e50241a310 Mon Sep 17 00:00:00 2001 From: Tony Bark Date: Wed, 30 Apr 2025 09:42:30 -0400 Subject: [PATCH 08/11] Updated roadmap --- README.md | 15 ++++++++------- S2PK.csproj | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8b3568f..1976792 100644 --- a/README.md +++ b/README.md @@ -6,27 +6,28 @@ S2PK, or Sims 2 Package Manager, aims to provide a simple cross-platform solutio While The Sims 2 runs well on Linux through Wine, especially with Lutris setups, and natively from macOS, only the Windows community had varies mod managers and installers compared to their cross-platform counterparts. Later installments addressed this dilemma, but TS2 never got that treatment. -``s2pk`` aims to fill this gap: a no-nonsense CLI utility for packaging, sharing, and managing mods across all platforms. It’s small, clean, and plays nicely with scripts, backups, and version control. In theory, it would be possible to use it on legacy front ends. +`s2pk` aims to fill this gap: a no-nonsense CLI utility for packaging, sharing, and managing mods across all platforms. It’s small, clean, and plays nicely with scripts, backups, and version control. In theory, it would be possible to use it on legacy front ends. ## πŸš€ Features - First-class CLI support for modders on non-Windows platforms - Custom default unpacking directory for The Sims 2 & 3 -- Pack ``.packages`` into portable ``.s2pk`` archives +- Pack `.packages` into portable `.s2pk` archives ## πŸ›£οΈ Project Roadmap | Phase | Goal | Status | | ----- | ------------------------------------------- | ------ | -| v0.1 | Core package manager | βœ… | -| v0.2 | Config file with default destination | πŸ”œ | +| v0.1 | Core package manager | βœ… | +| v0.2 | Config file with default paths | βœ… | +| v0.3 | Sims 3 support with `s3pk` extention | πŸ”œ | | v0.x | Target .NET 10 | πŸ”œ | | v1.0 | Stable "Release" version with documentation | πŸ”œ | ## 🎯 Stretch Goals - [ ] Manifest validation -- [ ] ``s1pk`` soft fork +- [ ] `s1pk` soft fork ## 🧩 Tech Stack @@ -43,13 +44,13 @@ While The Sims 2 runs well on Linux through Wine, especially with Lutris setups, ## πŸ› οΈ Installation -You can build yourself with ``make``, or use the installer script: +You can build yourself with `make`, or use the installer script: ```shell ./install.sh ./dist/s2pk-linux/s2pkg ``` -Make sure ``~/.local/bin`` is in your ``PATH``: +Make sure `~/.local/bin` is in your `PATH`: ```shell echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc diff --git a/S2PK.csproj b/S2PK.csproj index 4747aeb..9adff19 100644 --- a/S2PK.csproj +++ b/S2PK.csproj @@ -3,7 +3,7 @@ Exe net8.0 - 0.2.101 + 0.3.101 enable enable Tony Bark From a773f267f7357da70c12d99aaa9a05426f588266 Mon Sep 17 00:00:00 2001 From: Tony Bark Date: Wed, 30 Apr 2025 10:06:41 -0400 Subject: [PATCH 09/11] Unpacking now accounts for a lot more cases --- PackageManger.cs | 32 ++++++++++++++++++++++++++++---- Program.cs | 17 +++++++++++------ 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/PackageManger.cs b/PackageManger.cs index f22dfdc..7f27084 100644 --- a/PackageManger.cs +++ b/PackageManger.cs @@ -8,16 +8,23 @@ public static class PackageManager const string S2pkExtension = ".s2pk"; const string S3pkExtension = ".s3pk"; + /// + /// Returns the extension for the package file. + /// + /// Whether to use the Sims 3 extension. + /// The extension for the package file. + static string ExtensionHandler(bool ts3 = false) => ts3 ? S3pkExtension : S2pkExtension; + /// /// Packs a directory into a package file. /// /// The source directory. - /// The output package file. - public static void PackPackages(string source, string output) + /// The output package file. + public static void PackPackages(string source, string package, bool ts3 = false) { var dir = new DirectoryInfo(source); - var file = new FileInfo(output); - var extention = S2pkExtension; + var file = new FileInfo(package); + var extension = ExtensionHandler(ts3); if (!dir.Exists) { @@ -51,6 +58,8 @@ public static class PackageManager /// Whether to unpack for The Sims 3. public static void UnpackPackages(string package, string destination = "", bool ts3 = false) { + var extension = ExtensionHandler(ts3); + // If destination is not provided, read from configuration file if (string.IsNullOrEmpty(destination)) { @@ -63,6 +72,14 @@ public static class PackageManager destination = config.Paths.Sims3; } + // Check if destination directory exists + if (!Directory.Exists(destination)) + { + Console.Error.WriteLine("Destination directory does not exist."); + return; + } + + var file = new FileInfo(package); var dir = new DirectoryInfo(destination); @@ -72,6 +89,13 @@ public static class PackageManager return; } + // Check for extension mismatch + if (file.FullName.Contains(S3pkExtension) && !ts3) + { + Console.Error.WriteLine("Package is for The Sims 3 but unpacking for The Sims 2."); + return; + } + dir.Create(); // Ensures directory exists using var archive = ZipFile.OpenRead(file.FullName); diff --git a/Program.cs b/Program.cs index ba595e0..6ab3c17 100644 --- a/Program.cs +++ b/Program.cs @@ -2,6 +2,11 @@ using System.CommandLine; var rootCommand = new RootCommand("The Sims 2 .s2pk Package Manager"); +var sims3option = new Option( + aliases: ["--ts3"], + description: "Switch to The Sims 3 mode.", + getDefaultValue: () => false); + var sourceOption = new Option( aliases: ["--source", "-s"], description: "Source directory containing .package files") @@ -19,10 +24,10 @@ var packCommand = new Command("pack", "Packs .package files into a .s2pk archive outputOption }; -packCommand.SetHandler((source, output) => +packCommand.SetHandler((source, output, sims3) => { - PackageManager.PackPackages(source, output); -}, sourceOption, outputOption); + PackageManager.PackPackages(source, output, sims3); +}, sourceOption, outputOption, sims3option); var packageOption = new Option( aliases: ["--package", "-p"], @@ -40,10 +45,10 @@ var unpackCommand = new Command("unpack", "Unpacks a .s2pk archive to the Downlo destinationOption }; -unpackCommand.SetHandler((package, destination) => +unpackCommand.SetHandler((package, destination, sims3) => { - PackageManager.UnpackPackages(package, destination); -}, packageOption, destinationOption); + PackageManager.UnpackPackages(package, destination, sims3); +}, packageOption, destinationOption, sims3option); // Register commands rootCommand.AddCommand(packCommand); From 467cbea8d4be60ca8676dea2c44a458aa5198c14 Mon Sep 17 00:00:00 2001 From: Tony Bark Date: Wed, 30 Apr 2025 10:28:45 -0400 Subject: [PATCH 10/11] More unpacking checks --- PackageManger.cs | 6 ++++++ README.md | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/PackageManger.cs b/PackageManger.cs index 7f27084..90dd948 100644 --- a/PackageManger.cs +++ b/PackageManger.cs @@ -83,6 +83,12 @@ public static class PackageManager var file = new FileInfo(package); var dir = new DirectoryInfo(destination); + if (!file.FullName.Contains(extension)) + { + Console.Error.WriteLine("Package file is not a valid."); + return; + } + if (!file.Exists) { Console.Error.WriteLine("Package file does not exist."); diff --git a/README.md b/README.md index 1976792..85574da 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ While The Sims 2 runs well on Linux through Wine, especially with Lutris setups, You can build yourself with `make`, or use the installer script: ```shell -./install.sh ./dist/s2pk-linux/s2pkg +./install.sh ./dist/s2pk-linux/s2pk ``` Make sure `~/.local/bin` is in your `PATH`: From 6f54963287aa48467ebc5db030133d0d75fb0b6d Mon Sep 17 00:00:00 2001 From: Tony Bark Date: Wed, 30 Apr 2025 10:31:37 -0400 Subject: [PATCH 11/11] Extension checking happens after it checks if it even exists --- PackageManger.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/PackageManger.cs b/PackageManger.cs index 90dd948..ace0601 100644 --- a/PackageManger.cs +++ b/PackageManger.cs @@ -83,18 +83,19 @@ public static class PackageManager var file = new FileInfo(package); var dir = new DirectoryInfo(destination); - if (!file.FullName.Contains(extension)) - { - Console.Error.WriteLine("Package file is not a valid."); - return; - } - if (!file.Exists) { Console.Error.WriteLine("Package file does not exist."); return; } + + if (!file.FullName.Contains(extension)) + { + Console.Error.WriteLine("Package file is not a valid."); + return; + } + // Check for extension mismatch if (file.FullName.Contains(S3pkExtension) && !ts3) {