mirror of
https://github.com/keylase/nvidia-patch.git
synced 2025-08-06 14:53:53 -07:00
ap: ensure only one occurence
This commit is contained in:
parent
0ea7227035
commit
8eb2b50a9a
1 changed files with 6 additions and 1 deletions
|
@ -59,6 +59,9 @@ class ExtractException(Exception):
|
|||
class PatternNotFoundException(Exception):
|
||||
pass
|
||||
|
||||
class MultipleOccurencesException(Exception):
|
||||
pass
|
||||
|
||||
class UnknownPlatformException(Exception):
|
||||
pass
|
||||
|
||||
|
@ -130,9 +133,11 @@ def make_patch(archive, *,
|
|||
sevenzip=sevenzip) as tgt:
|
||||
f = expand(tgt, sevenzip=sevenzip)
|
||||
offset = f.find(search)
|
||||
del f
|
||||
if offset == -1:
|
||||
raise PatternNotFoundException("Pattern not found.")
|
||||
if f[offset+len(search):].find(search) != -1:
|
||||
raise MultipleOccurencesException("Multiple occurences of pattern found!")
|
||||
del f
|
||||
print("Pattern found @ %016X" % (offset,), file=sys.stderr)
|
||||
|
||||
res = []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue