diff --git a/.gitignore b/.gitignore index 3b3fc40..ca3b051 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,40 @@ # File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig -# Created by https://www.toptal.com/developers/gitignore/api/linux,macos,visualstudio,visualstudiocode,windows -# Edit at https://www.toptal.com/developers/gitignore?templates=linux,macos,visualstudio,visualstudiocode,windows +# Created by https://www.toptal.com/developers/gitignore/api/windows,visualstudiocode,visualstudio,macos,linux,archives +# Edit at https://www.toptal.com/developers/gitignore?templates=windows,visualstudiocode,visualstudio,macos,linux,archives + +### Archives ### +# It's better to unpack these files and commit the raw source because +# git has its own built in compression methods. +*.7z +*.jar +*.rar +*.zip +*.gz +*.gzip +*.tgz +*.bzip +*.bzip2 +*.bz2 +*.xz +*.lzma +*.cab +*.xar + +# Packing-only formats +*.iso +*.tar + +# Package management formats +*.dmg +*.xpi +*.gem +*.egg +*.deb +*.rpm +*.msi +*.msm +*.msp +*.txz ### Linux ### *~ @@ -86,11 +120,7 @@ ehthumbs_vista.db $RECYCLE.BIN/ # Windows Installer files -*.cab -*.msi *.msix -*.msm -*.msp # Windows shortcuts *.lnk @@ -484,7 +514,9 @@ FodyWeavers.xsd ### VisualStudio Patch ### # Additional files built by Visual Studio -# End of https://www.toptal.com/developers/gitignore/api/linux,macos,visualstudio,visualstudiocode,windows +# End of https://www.toptal.com/developers/gitignore/api/windows,visualstudiocode,visualstudio,macos,linux,archives # Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option) +*.s1pk +*.iff \ No newline at end of file diff --git a/README.md b/README.md index 7dacbe4..f2aa3e3 100644 --- a/README.md +++ b/README.md @@ -4,24 +4,34 @@ Sims1Pack, or ``s1pk``, is a custom ZIP-based s1pk format designed to enhance th ## SimGet + SimGet is a simple command-line package manager designed to work with the ``s1pk`` format. At this stage, it provides support for extracting files. Packaging will need to be performed manually for now. SimGet serves as a reference implementation for the format. Below are the basic usage instructions: ### Usage To extract an ``s1pk`` file, use the following command: -```shell -simget extract --file --directory +```text +-d, --destination + +-f, --file + +-v, --verbose + +-s, --simulate + +--help Display this help screen. + +--version Display version information. ``` -- `` should be replaced with the path to the s1pk file you want to extract. -- `` is the location where the contents of the ``s1pk`` file will be extracted to. +- In simulation mode, the destination doesn't need to be specified ### Platform Specifics #### Windows -On Windows, SimGet defaults to the Complete Collection install directory for The Sims 1. This makes it convenient to work with mods and custom content in the Windows environment. +On Windows, SimGet defaults to the Complete Collection install directory for The Sims 1. #### Other Platforms diff --git a/SimGet/Manifest.cs b/SimGet/Manifest.cs new file mode 100644 index 0000000..029b79c --- /dev/null +++ b/SimGet/Manifest.cs @@ -0,0 +1,30 @@ +// A custom ZIP-based format designed to enhance the Sims 1 modding experience. +// Copyright (C) 2023 Tony Bark +// +// This program is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by the Free +// Software Foundation, either version 3 of the License, or (at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +// more details. +// +// You should have received a copy of the GNU General Public License along with +// this program. If not, see . +using System.Text.Json.Serialization; + +namespace S1Util; + +public record Manifest +{ + [JsonPropertyName("version")] + public string Version { get; set; } = "1.0"; + + [JsonPropertyName("author")] + public string Author { get; set; } = Environment.UserName; + + [JsonPropertyName("files")] + public string[] Files { get; set; } = new string[] { }; +} \ No newline at end of file diff --git a/SimGet/Options.cs b/SimGet/Options.cs index e4abbb2..9e2ec72 100644 --- a/SimGet/Options.cs +++ b/SimGet/Options.cs @@ -17,13 +17,14 @@ namespace S1Util; public class Options { - [Option('d', "dir")] public string Directory { get; set; } = string.Empty; + [Option('d', "destination")] public string Destination { get; set; } = string.Empty; [Option('f', "file", Required = true)] public string File { get; set; } = string.Empty; - [Option('s', "simulate")] public bool Simulate { get; set; } = false; + [Option('v', "verbose")] public bool Verbose { get; set; } = false; + [Option('s', "simulate", HelpText = "Simulate the extraction or compression process.")] public bool Simulate { get; set; } = false; } -[Verb("extract")] +[Verb("extract", HelpText = "Extract .s1pk archives.")] public class Extract : Options { } -[Verb("compress")] +[Verb("compress", HelpText = "Compress .s1pk files.")] public class Compress : Options { } \ No newline at end of file diff --git a/SimGet/PackUtil.cs b/SimGet/PackUtil.cs index 2c401a2..87e3b50 100644 --- a/SimGet/PackUtil.cs +++ b/SimGet/PackUtil.cs @@ -19,30 +19,34 @@ namespace S1Util; public class PackUtil { - public PackUtil(string directory, string file) + public PackUtil(string destination, string file, bool simulate) { - OutputPath = directory; + Destination = destination; FilePath = file; + Simulate = simulate; } - string OutputPath { get; set; } = string.Empty; + string Destination { get; set; } = string.Empty; string FilePath { get; set; } = string.Empty; + bool Simulate { get; set; } = false; - void PathDetection() + void PathResolver() { var os = Environment.OSVersion; - if (os.Platform == PlatformID.Win32NT && OutputPath == string.Empty) + if (Simulate) Destination = Environment.CurrentDirectory; + + if (os.Platform == PlatformID.Win32NT && Destination == string.Empty && !Simulate) { // TODO Presumed location. I haven't played the game in a while. var progFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86); var gamePath = Path.Combine(progFiles, "The Sims Complete Collection", "Downloads"); - OutputPath = gamePath; + Destination = gamePath; } // Check if game directory exists - if (!Directory.Exists(OutputPath)) + if (!Directory.Exists(Destination) && !Simulate) { Console.WriteLine("Game not found."); Environment.Exit(Environment.ExitCode); @@ -65,9 +69,9 @@ void PathDetection() } } - public void Extract(bool simulate = false) + public void Extract() { - PathDetection(); + PathResolver(); // Extract the s1pk file using var archive = ZipFile.OpenRead(FilePath); @@ -75,17 +79,35 @@ public void Extract(bool simulate = false) foreach (ZipArchiveEntry entry in archive.Entries) { // Check if the entry has the .iff extension - if (entry.FullName.EndsWith(".iff", StringComparison.InvariantCultureIgnoreCase) && !simulate) + if (entry.FullName.EndsWith(".iff", StringComparison.InvariantCultureIgnoreCase)) { // Build the full path for the extracted file - string extractFilePath = Path.Combine(OutputPath, entry.FullName); + var extractFilePath = Path.Combine(Destination, entry.FullName); + + Console.WriteLine(extractFilePath); // Extract the file - entry.ExtractToFile(extractFilePath, true); + if (!Simulate) entry.ExtractToFile(extractFilePath, true); } } Console.WriteLine("Extraction completed successfully."); } + + public void Compress() + { + var files = Directory.GetFiles(Destination); + // using var archive = ZipFile.CreateFromDirectory() + + foreach (var file in files) + { + if (file.EndsWith("iff", StringComparison.InvariantCultureIgnoreCase)) + { + + } + } + + throw new NotImplementedException(); + } } \ No newline at end of file diff --git a/SimGet/Program.cs b/SimGet/Program.cs index 28df088..a9e289e 100644 --- a/SimGet/Program.cs +++ b/SimGet/Program.cs @@ -18,20 +18,19 @@ Parser.Default.ParseArguments(args) .WithParsed(opts => { - var dirPath = opts.Directory; + var dirPath = opts.Destination; var zipPath = opts.File; - var unpack = new PackUtil(zipPath, dirPath); - unpack.Extract(opts.Simulate); + var unpack = new PackUtil(zipPath, dirPath, opts.Simulate); + unpack.Extract(); }) .WithParsed(opts => { - var dirPath = opts.Directory; + var dirPath = opts.Destination; var zipPath = opts.File; - var compress = new PackUtil(zipPath, dirPath); - - throw new NotImplementedException(); + var compress = new PackUtil(zipPath, dirPath, opts.Simulate); + compress.Compress(); }); \ No newline at end of file diff --git a/docs/.gitkeep b/docs/.gitkeep deleted file mode 100644 index e69de29..0000000