Skip to content

Commit 34310ff

Browse files
committed
Added overloads.
1 parent 6a70246 commit 34310ff

3 files changed

Lines changed: 52 additions & 1 deletion

File tree

LibIPS.NET/Creator.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ class Creator
3636

3737
// There are no known cases where LIPS wins over libips.
3838

39+
public void Create(MemoryStream source, MemoryStream target, MemoryStream patch)
40+
{
41+
Create((Stream)source, (Stream)target, (Stream)patch);
42+
}
43+
3944
/// <summary>
4045
/// Creates an IPS patch file from a source file path and a target file path.
4146
/// </summary>

LibIPS.NET/Patcher.cs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ class Patcher
1111
public const string PatchText = "PATCH";
1212
public const int EndOfFile = 0x454F46;
1313

14+
public void PatchStudy(MemoryStream patch, Studier.IpsStudy study, MemoryStream source, MemoryStream target)
15+
{
16+
PatchStudy((Stream)patch, study, (Stream)source, (Stream)target);
17+
}
18+
public void PatchStudy(string patch, Studier.IpsStudy study, string source, string target)
19+
{
20+
using (FileStream patchStream = File.OpenRead(patch), sourceStream = File.OpenRead(source), targetStream = File.Open(target, FileMode.Create))
21+
{
22+
PatchStudy(patchStream, study, sourceStream, targetStream);
23+
}
24+
}
25+
public void PatchStudy(FileStream patch, Studier.IpsStudy study, FileStream source, FileStream target)
26+
{
27+
PatchStudy((Stream)patch, study, (Stream)source, (Stream)target);
28+
}
1429
public void PatchStudy(Stream patch, Studier.IpsStudy study, Stream source, Stream target)
1530
{
1631
source.CopyTo(target);
@@ -46,13 +61,28 @@ public void PatchStudy(Stream patch, Studier.IpsStudy study, Stream source, Stre
4661
}
4762
if (study.OutlenMax != 0xFFFFFFFF && source.Length <= study.OutlenMax) throw new Exceptions.IpsNotThisException(); // Truncate data without this being needed is a poor idea.
4863
}
64+
public void Patch(MemoryStream patch, MemoryStream source, MemoryStream target)
65+
{
66+
Patch((Stream)patch, (Stream)source, (Stream)target);
67+
}
68+
public void Patch(string patch, string source, string target)
69+
{
70+
using (FileStream patchStream = File.OpenRead(patch), sourceStream = File.OpenRead(source), targetStream = File.Open(target, FileMode.Create))
71+
{
72+
Patch(patchStream, sourceStream, targetStream);
73+
}
74+
}
75+
public void Patch(FileStream patch, FileStream source, FileStream target)
76+
{
77+
Patch((Stream)patch, (Stream)source, (Stream)target);
78+
}
4979
public void Patch(Stream patch, Stream source, Stream target)
5080
{
5181
Studier studier = new Studier();
5282
Studier.IpsStudy study = studier.Study(patch);
5383
PatchStudy(patch, study, source, target);
5484
}
55-
public static long Clamp(long value, long minimum, long maximum)
85+
private static long Clamp(long value, long minimum, long maximum)
5686
{
5787
return (value < minimum) ? minimum : (value > maximum) ? maximum : value;
5888
}

LibIPS.NET/Studier.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,22 @@ public struct IpsStudy
3232
public long OutlenMax;
3333
public long OutlenMinMem;
3434
};
35+
public IpsStudy Study(MemoryStream patch)
36+
{
37+
return Study((Stream)patch);
38+
}
39+
public IpsStudy Study(string patch)
40+
{
41+
using(FileStream patchStream = File.OpenRead(patch))
42+
{
43+
return Study(patchStream);
44+
}
45+
}
46+
public IpsStudy Study(FileStream patch)
47+
{
48+
return Study((Stream)patch);
49+
}
50+
3551
public IpsStudy Study(Stream patch)
3652
{
3753
IpsStudy study = new IpsStudy();

0 commit comments

Comments
 (0)