Skip to content

Commit

Permalink
Final updates for 1.7.1 - Added Command line version
Browse files Browse the repository at this point in the history
Fixes #11
  • Loading branch information
Sappharad committed Nov 24, 2020
1 parent 277c3fa commit e0e4724
Show file tree
Hide file tree
Showing 10 changed files with 441 additions and 183 deletions.
162 changes: 51 additions & 111 deletions Base.lproj/MainMenu.xib

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion MPPatchResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface MPPatchResult : NSObject
+(MPPatchResult*)newMessage:(NSString*)message isWarning:(BOOL)warning;
@property BOOL IsWarning;
@property NSString* Message;
@property (assign) NSString* Message;

@end

Expand Down
17 changes: 17 additions & 0 deletions MPSettings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// MPSettings.h
// MultiPatch
//
// Created by Paul Kratt on 11/24/20.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface MPSettings : NSObject
@property (class) BOOL IgnoreXDeltaChecksum;

@end

NS_ASSUME_NONNULL_END
20 changes: 20 additions & 0 deletions MPSettings.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// MPSettings.m
// MultiPatch
//
// Created by Paul Kratt on 11/24/20.
//

#import "MPSettings.h"

@implementation MPSettings

static BOOL _ignoreXDeltaChecksum;
+(BOOL)IgnoreXDeltaChecksum{
return _ignoreXDeltaChecksum;
}
+(void)setIgnoreXDeltaChecksum:(BOOL)value{
_ignoreXDeltaChecksum = value;
}

@end
260 changes: 210 additions & 50 deletions MultiPatch.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion MultiPatchController.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ NS_ASSUME_NONNULL_BEGIN
@interface MultiPatchController : NSObject<NSApplicationDelegate>
@property (assign) IBOutlet NSWindow *wndPreferences;
@property (assign) IBOutlet NSButton *chkIgnoreXDelta;
@property (class) BOOL IgnoreXDeltaChecksum;

- (IBAction)showPreferences:(id)sender;
- (IBAction)chkIgnoreXdeltaChecks:(id)sender;
Expand Down
13 changes: 3 additions & 10 deletions MultiPatchController.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

#import "MultiPatchController.h"
#import "MPSettings.h"

@implementation MultiPatchController

Expand All @@ -15,22 +16,14 @@ -(void)applicationDidFinishLaunching:(NSNotification *)notification{
//User tries patching, program notifies them that their input file is wrong.
//User goes into preferences and disables the check and applies patch again.
//User gets a file that might work, but might not, since their input was wrong.
_ignoreXDeltaChecksum = NO;
MPSettings.IgnoreXDeltaChecksum = NO;
}

- (IBAction)showPreferences:(id)sender {
[_wndPreferences makeKeyAndOrderFront:self];
}

- (IBAction)chkIgnoreXdeltaChecks:(id)sender {
MultiPatchController.IgnoreXDeltaChecksum = (_chkIgnoreXDelta.state==NSOnState);
}

static BOOL _ignoreXDeltaChecksum;
+(BOOL)IgnoreXDeltaChecksum{
return _ignoreXDeltaChecksum;
}
+(void)setIgnoreXDeltaChecksum:(BOOL)value{
_ignoreXDeltaChecksum = value;
MPSettings.IgnoreXDeltaChecksum = (_chkIgnoreXDelta.state==NSOnState);
}
@end
20 changes: 13 additions & 7 deletions ReadMe.rtf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{\rtf1\ansi\ansicpg1252\cocoartf1671\cocoasubrtf500
\cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;\f1\fswiss\fcharset0 Helvetica;\f2\fnil\fcharset0 HelveticaNeue-Bold;
{\rtf1\ansi\ansicpg1252\cocoartf2576
\cocoascreenfonts1\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;\f1\fswiss\fcharset0 Helvetica;\f2\fnil\fcharset0 HelveticaNeue-Bold;
}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\margl1440\margr1440\vieww11020\viewh8400\viewkind0
\pard\tx720\tx1440\tx2160\tx2250\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0

\f0\fs36 \cf0 \uldb \ulc0 MultiPatch 1.7
\f0\fs36 \cf0 \uldb \ulc0 MultiPatch 1.7.1
\f1\fs24 \ulnone \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
\cf0 \
Expand All @@ -15,7 +15,7 @@
MultiPatch is a patch utility for macOS. If you downloaded this, you probably already know that. MultiPatch is free software made up of several open source projects under varying licenses. See the license and source code sections below for more details.\
\
\ul System Requirements\ulnone \
1. Any system running macOS 10.7 or greater.\
1. Any system running macOS 10.9 or greater.\
2. Enough hard drive space to save a copy of the files you're planning to patch.\
\
\ul Instructions\ulnone \
Expand Down Expand Up @@ -78,7 +78,14 @@ https://github.com/Sappharad/MultiPatch/\
If you have changes that you'd like to contribute to the application, pull requests are welcome.\
\
\ul Version History\
\ulnone 1.7 - December 14th 2018\
\ulnone 1.7.1 - November 24th 2020\
- Added native support for Apple Silicon Macs.\
- macOS 10.9 or later is now required due to requirements for supporting newer Macs. Previous versions will remain available for download for older Macs.\
- Updated Floating IPS code to the latest version, which might have some bug fixes.\
- Includes text corrections submitted by Eric Newport; some instances of the app name MultiPatch contained a space.\
- Added command line version as a separate download on the website.\
\
1.7 - December 14th 2018\
- Fixed: PPF Patches did not apply correctly most of the time. (This LibPPF bug was originally documented by Ritesh Sood on SourceForge)\
- Switched IPS, UPS and BPS support to the Floating IPS library. It appears to be the preferred library for creating and applying IPS and BPS patches now, creating the most efficient patches and offering the best patch compatibility.\
- Added support for applying Ninja 2 .rup patches.\
Expand Down Expand Up @@ -127,8 +134,7 @@ If you have changes that you'd like to contribute to the application, pull reque
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
\f0\b0 \cf0 \ulnone Paul Kratt\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
\cf0 \
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0

\f2\b \cf0 Text Corrections
Expand Down
6 changes: 3 additions & 3 deletions XDeltaAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//

#import "XDeltaAdapter.h"
#import "MultiPatchController.h"
#import "MPSettings.h"
#include "xdelta3.h"

@implementation XDeltaAdapter
Expand All @@ -24,7 +24,7 @@ +(MPPatchResult*)ApplyPatch:(NSString*)patch toFile:(NSString*)input andCreate:(
}
return [MPPatchResult newMessage:[NSString stringWithFormat:@"Decode error: %d",r] isWarning:NO];
}
if(MultiPatchController.IgnoreXDeltaChecksum){
if(MPSettings.IgnoreXDeltaChecksum){
return [MPPatchResult newMessage:@"Patching was completed. Remember that you ignored the checksum so the output file might not work if the input was bad." isWarning:YES];
}

Expand Down Expand Up @@ -64,7 +64,7 @@ int code (int encode, FILE* InFile, FILE* SrcFile, FILE* OutFile, int BufSize)
memset (&stream, 0, sizeof (stream));
memset (&source, 0, sizeof (source));

if(MultiPatchController.IgnoreXDeltaChecksum){
if(MPSettings.IgnoreXDeltaChecksum){
//We still want to generate a checksum either way, but this disables checking it for the apply operation.
xd3_init_config(&config, XD3_ADLER32 | XD3_ADLER32_NOVER);
}
Expand Down
123 changes: 123 additions & 0 deletions cmdMultiPatch/main.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
//
// main.m
// cmdMultiPatch
//
// Created by Paul Kratt on 11/24/20.
//

#import <Foundation/Foundation.h>
#import "XDeltaAdapter.h"
#import "IPSAdapter.h"
#import "PPFAdapter.h"
#import "BSdiffAdapter.h"
#import "BPSAdapter.h"
#import "UPSAdapter.h"
#import "RUPAdapter.h"

int applyPatch(NSString* patch, NSString* input, NSString* output);
int createPatch(NSString* oldPath, NSString* newPath, NSString* output);

int main(int argc, const char * argv[]) {
@autoreleasepool {
printf("MultiPatch Command Line\n");
if(argc != 5){
printf("Call this with one of the following sets of arguments:\n");
printf(" --apply [patchFile] [inputFile] [outFile]\n");
printf(" --create [oldFile] [newFile] [patchFile]\n");
return 1;
}
NSMutableArray<NSString*>* strArgs = [NSMutableArray<NSString*> new];
for (int i=0; i<argc; i++) {
[strArgs addObject:[NSString stringWithCString:argv[i] encoding:NSUTF8StringEncoding]];
}
if(!([[strArgs objectAtIndex:1] isEqualToString:@"--apply"] || [[strArgs objectAtIndex:1] isEqualToString:@"--create"])){
printf("Unexpected argument: %s\n",[[strArgs objectAtIndex:1] UTF8String]);
return 1;
}
NSFileManager* fman = [NSFileManager new];
if(![fman fileExistsAtPath:[strArgs objectAtIndex:2]]){
printf("File not found: %s\n", [[strArgs objectAtIndex:2] UTF8String]);
return 1;
}
if(![fman fileExistsAtPath:[strArgs objectAtIndex:3]]){
printf("File not found: %s\n", [[strArgs objectAtIndex:3] UTF8String]);
return 1;
}
NSString* folder = [[strArgs objectAtIndex:4] stringByDeletingLastPathComponent];
if(folder.length > 1 && ![fman fileExistsAtPath:folder]){
printf("The folder where the output file should be created does not exist: %s\n", [[strArgs objectAtIndex:4] UTF8String]);
return 1;
}
//Files are good, let's get started
if([[strArgs objectAtIndex:1] isEqualToString:@"--apply"]){
return applyPatch([strArgs objectAtIndex:2], [strArgs objectAtIndex:3], [strArgs objectAtIndex:4]);
}
else if([[strArgs objectAtIndex:1] isEqualToString:@"--create"]){
return createPatch([strArgs objectAtIndex:2], [strArgs objectAtIndex:3], [strArgs objectAtIndex:4]);
}
}
return 0;
}

int applyPatch(NSString* patch, NSString* input, NSString* output){
MPPatchResult* retval = nil;
NSString* lowerPath = [patch lowercaseString];
if([lowerPath hasSuffix:@".ups"]){
retval = [UPSAdapter ApplyPatch:patch toFile:input andCreate:output];
}
else if([lowerPath hasSuffix:@".ips"]){
retval = [IPSAdapter ApplyPatch:patch toFile:input andCreate:output];
}
else if([lowerPath hasSuffix:@".ppf"]){
retval = [PPFAdapter ApplyPatch:patch toFile:input andCreate:output];
}
else if([lowerPath hasSuffix:@".dat"] || [lowerPath hasSuffix:@"delta"]){
retval = [XDeltaAdapter ApplyPatch:patch toFile:input andCreate:output];
}
else if([lowerPath hasSuffix:@".bdf"] || [lowerPath hasSuffix:@".bsdiff"]){
retval = [BSdiffAdapter ApplyPatch:patch toFile:input andCreate:output];
}
else if([lowerPath hasSuffix:@".bps"]){
retval = [BPSAdapter ApplyPatch:patch toFile:input andCreate:output];
}
else if([lowerPath hasSuffix:@".rup"]){
retval = [RUPAdapter ApplyPatch:patch toFile:input andCreate:output];
}
if(retval != nil){
printf("%s\n",[retval.Message UTF8String]);
if(!retval.IsWarning){
return 1;
}
}
printf("Done patching!\n");
return 0;
}

int createPatch(NSString* oldPath, NSString* newPath, NSString* output){
MPPatchResult* retval = nil;
NSString* lowerPath = [output lowercaseString];
if([lowerPath hasSuffix:@".ips"]){
retval = [IPSAdapter CreatePatch:oldPath withMod:newPath andCreate:output];
}
else if([lowerPath hasSuffix:@".dat"] || [lowerPath hasSuffix:@"delta"]){
retval = [XDeltaAdapter CreatePatch:oldPath withMod:newPath andCreate:output];
}
else if([lowerPath hasSuffix:@".bdf"] || [lowerPath hasSuffix:@".bsdiff"]){
retval = [BSdiffAdapter CreatePatch:oldPath withMod:newPath andCreate:output];
}
else if([lowerPath hasSuffix:@".bps"]){
retval = [BPSAdapter CreatePatchDelta:oldPath withMod:newPath andCreate:output];
}
else{
printf("Cannot create patch for unsupported file type: %s\n", [output UTF8String]);
return 1;
}
if(retval != nil){
printf("%s\n",[retval.Message UTF8String]);
if(!retval.IsWarning){
return 1;
}
}
printf("Patch created!\n");
return 0;
}

0 comments on commit e0e4724

Please sign in to comment.