Skip to content

Commit

Permalink
- Using readonly flags with SFmpq for things that only need to read
Browse files Browse the repository at this point in the history
  • Loading branch information
zzahos-kg committed Nov 25, 2015
1 parent 9eb0171 commit c1a39e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Libs/setutils.py
Expand Up @@ -187,7 +187,7 @@ def open_mpqs(self):
if not os.path.exists(m):
missing[0].append(m)
continue
handles[m] = SFileOpenArchive(m, len(self.mpqs)-p)
handles[m] = MpqOpenArchiveForUpdateEx(m, MOAU_OPEN_EXISTING | MOAU_MAINTAIN_LISTFILE)
if SFInvalidHandle(handles[m]):
missing[1].append(m)
elif self.open == True:
Expand All @@ -207,7 +207,7 @@ def close_mpqs(self):
self.open = False
for h in self.handles.values():
if not SFInvalidHandle(h):
SFileCloseArchive(h)
MpqCloseUpdatedArchive(h)
self.handles = {}

# folder(True)=Get only from folder,folder(None)=Get from either, MPQ first, folder second,folder(False)=Get only from MPQ
Expand Down
12 changes: 6 additions & 6 deletions PyMPQ.pyw
Expand Up @@ -757,7 +757,7 @@ class PyMPQ(Tk):
close = False
if h == -1:
close = True
h = MpqOpenArchiveForUpdate(self.file, MOAU_OPEN_EXISTING)
h = MpqOpenArchiveForUpdate(self.file, MOAU_OPEN_EXISTING | MOAU_READ_ONLY)
if SFInvalidHandle(h):
raise
self.files = []
Expand Down Expand Up @@ -826,7 +826,7 @@ class PyMPQ(Tk):
close = False
if h == None:
close = True
h = MpqOpenArchiveForUpdate(self.file, MOAU_OPEN_EXISTING)
h = MpqOpenArchiveForUpdate(self.file, MOAU_OPEN_EXISTING | MOAU_READ_ONLY)
if SFInvalidHandle(h):
raise
f = SFileGetFileInfo(h,SFILE_INFO_NUM_FILES)
Expand Down Expand Up @@ -887,7 +887,7 @@ class PyMPQ(Tk):

def openfile(self, e=None):
path = os.path.join(BASE_DIR,'Libs','Temp',str(self.id))
h = SFileOpenArchive(self.file)
h = MpqOpenArchiveForUpdate(self.file, MOAU_OPEN_EXISTING | MOAU_READ_ONLY)
if SFInvalidHandle(h):
raise
for i in self.listbox.cur_selection():
Expand All @@ -908,7 +908,7 @@ class PyMPQ(Tk):
start_new_thread(os.system, ('"%s"' % fn,))
if not self.thread:
self.thread.start()
SFileCloseArchive(h)
MpqCloseUpdatedArchive(h)

def update_files(self, fs):
p = os.path.join(BASE_DIR,'Libs','Temp',str(self.id),'')
Expand Down Expand Up @@ -954,7 +954,7 @@ class PyMPQ(Tk):
file = self.select_file('Open MPQ')
if not file:
return
h = MpqOpenArchiveForUpdateEx(file)
h = MpqOpenArchiveForUpdateEx(file, MOAU_OPEN_EXISTING | MOAU_READ_ONLY)
if SFInvalidHandle(h):
askquestion(parent=self, title='Open', message='There is no MPQ in "%s".' % file, type=OK)
return
Expand All @@ -963,7 +963,7 @@ class PyMPQ(Tk):
self.status.set('Load Successful!')
self.list_files(h)
self.update_info(h)
SFileCloseArchive(h)
MpqCloseUpdatedArchive(h)
self.update_list()
self.select()

Expand Down

0 comments on commit c1a39e2

Please sign in to comment.