rclchm: close file (windows temp file removal)

This commit is contained in:
Jean-Francois Dockes 2019-07-20 19:08:33 +02:00
parent 2c454b92a6
commit 7d168dc198

View File

@ -284,7 +284,10 @@ class rclCHM:
charset = 'cp1252' charset = 'cp1252'
text = text.decode(charset, errors='replace') text = text.decode(charset, errors='replace')
return text, charset return text, charset
def closefile(self):
self.chm.CloseCHM()
def openfile(self, params): def openfile(self, params):
"""Open the chm file and build the contents list by extracting and """Open the chm file and build the contents list by extracting and
parsing the Topics object""" parsing the Topics object"""
@ -339,6 +342,7 @@ class rclCHM:
if self.catenate: if self.catenate:
self.em.setmimetype("text/plain") self.em.setmimetype("text/plain")
alltxt = self.dumpall() alltxt = self.dumpall()
self.closefile()
if alltxt: if alltxt:
return (True, alltxt, "", rclexecm.RclExecM.eofnext) return (True, alltxt, "", rclexecm.RclExecM.eofnext)
else: else:
@ -349,15 +353,20 @@ class rclCHM:
self.currentindex = 0 self.currentindex = 0
self.em.setmimetype('text/plain') self.em.setmimetype('text/plain')
if len(self.contents) == 0: if len(self.contents) == 0:
self.closefile()
eof = rclexecm.RclExecM.eofnext eof = rclexecm.RclExecM.eofnext
else: else:
eof = rclexecm.RclExecM.noteof eof = rclexecm.RclExecM.noteof
return (True, "", "", eof) return (True, "", "", eof)
if self.currentindex >= len(self.contents): if self.currentindex >= len(self.contents):
self.closefile()
return (False, "", "", rclexecm.RclExecM.eofnow) return (False, "", "", rclexecm.RclExecM.eofnow)
else: else:
ret= self.extractone(self.contents[self.currentindex]) ret = self.extractone(self.contents[self.currentindex])
if ret[3] == rclexecm.RclExecM.eofnext or \
ret[3] == rclexecm.RclExecM.eofnow:
self.closefile()
self.currentindex += 1 self.currentindex += 1
return ret return ret