def _update_prev_cabfile(self, filename): # Only execute if there is more than one cab in the set if len(self.cab_files) < 2: return # Get the previous cab and the current cab prev_cab = self.cab_files[-2] current_cab = self.cab_files[-1] if prev_cab.cfheader.flags & CFHEADER.cfhdrNEXT_CABINET != CFHEADER.cfhdrNEXT_CABINET: # We only need to update the szCabinetNext, szDiskNext and Flags once! # Set the NEXT_CABINET flag in the cfheader prev_cab.cfheader.flags |= CFHEADER.cfhdrNEXT_CABINET # Update strings in the cfheader indicating there is a next cab prev_cab.cfheader.szCabinetNext = CABFile.get_null_ended_string( current_cab.cab_filename) prev_cab.cfheader.szDiskNext = CABFile.get_null_ended_string( "continued") # Set IFolder on CFFILE to ifoldCONTINUED_TO_NEXT folder_list = prev_cab.cfheader.cffolder_list for folder in folder_list: for _cffile in folder.cffile_list: if _cffile.szName == CABFile.get_null_ended_string( filename): if _cffile.iFolder in CFFILE.get_iFolder_options(): _cffile.iFolder |= CFFILE.ifoldCONTINUED_TO_NEXT else: _cffile.iFolder = CFFILE.ifoldCONTINUED_TO_NEXT # Update offsets - We need to do this every time # because we've just added some strings into the structure prev_cab.update_fields()
def _update_prev_cabfile(self, filename): # Only execute if there is more than one cab in the set if len(self.cab_files) < 2: return # Get the previous cab and the current cab prev_cab = self.cab_files[-2] current_cab = self.cab_files[-1] if prev_cab.cfheader.flags & CFHEADER.cfhdrNEXT_CABINET != CFHEADER.cfhdrNEXT_CABINET: # We only need to update the szCabinetNext, szDiskNext and Flags once! # Set the NEXT_CABINET flag in the cfheader prev_cab.cfheader.flags |= CFHEADER.cfhdrNEXT_CABINET # Update strings in the cfheader indicating there is a next cab prev_cab.cfheader.szCabinetNext = CABFile.get_null_ended_string(current_cab.cab_filename) prev_cab.cfheader.szDiskNext = CABFile.get_null_ended_string("continued") # Set IFolder on CFFILE to ifoldCONTINUED_TO_NEXT folder_list = prev_cab.cfheader.cffolder_list for folder in folder_list: for _cffile in folder.cffile_list: if _cffile.szName == CABFile.get_null_ended_string(filename): if _cffile.iFolder in CFFILE.get_iFolder_options(): _cffile.iFolder |= CFFILE.ifoldCONTINUED_TO_NEXT else: _cffile.iFolder = CFFILE.ifoldCONTINUED_TO_NEXT # Update offsets - We need to do this every time # because we've just added some strings into the structure prev_cab.update_fields()
def _update_current_cabfile(self, filename, folder_name): # Only execute if there was more than one cab before inserting the current if len(self.cab_files) < 2: return # The last added cab is the current cab_file = self.cab_files[-1] if cab_file.cfheader.flags & CFHEADER.cfhdrPREV_CABINET != CFHEADER.cfhdrPREV_CABINET: # We only need to update the szCabinetPrev, szDiskPrev and Flags once! # Set PREVIOUS CABINET on the actual cab_file.cfheader.flags |= CFHEADER.cfhdrPREV_CABINET # MSDN - szCabinetPrev: # Note that this gives the name of the most-recently-preceding cabinet file that contains # the initial instance of a file entry. This might not be the immediately previous cabinet file, # when the most recent file spans multiple cabinet files. If searching in reverse for a specific file entry, # or trying to extract a file that is reported to begin in the "previous cabinet", # szCabinetPrev would give the name of the cabinet to examine. # We need to search for the first cabinet that holds part of the file prev_cab = self._find_first_cab_of_file(filename, folder_name) if prev_cab == None: # This is a border case where the last cabfile had the exact space requiered for the last file. prev_cab = self.cab_files[-2] cab_file.cfheader.szCabinetPrev = CABFile.get_null_ended_string( prev_cab.cab_filename) cab_file.cfheader.szDiskPrev = CABFile.get_null_ended_string( "previous") folder_list = cab_file.cfheader.cffolder_list for folder in folder_list: for _cffile in folder.cffile_list: if _cffile.szName == CABFile.get_null_ended_string( filename): if _cffile.iFolder in CFFILE.get_iFolder_options(): _cffile.iFolder |= CFFILE.ifoldCONTINUED_FROM_PREV else: _cffile.iFolder = CFFILE.ifoldCONTINUED_FROM_PREV # Update offsets - We need to do this every time # because we've just added some strings into the structure cab_file.update_fields()
def _update_current_cabfile(self, filename, folder_name): # Only execute if there was more than one cab before inserting the current if len(self.cab_files) < 2: return # The last added cab is the current cab_file = self.cab_files[-1] if cab_file.cfheader.flags & CFHEADER.cfhdrPREV_CABINET != CFHEADER.cfhdrPREV_CABINET: # We only need to update the szCabinetPrev, szDiskPrev and Flags once! # Set PREVIOUS CABINET on the actual cab_file.cfheader.flags |= CFHEADER.cfhdrPREV_CABINET # MSDN - szCabinetPrev: # Note that this gives the name of the most-recently-preceding cabinet file that contains # the initial instance of a file entry. This might not be the immediately previous cabinet file, # when the most recent file spans multiple cabinet files. If searching in reverse for a specific file entry, # or trying to extract a file that is reported to begin in the "previous cabinet", # szCabinetPrev would give the name of the cabinet to examine. # We need to search for the first cabinet that holds part of the file prev_cab = self._find_first_cab_of_file(filename, folder_name) if prev_cab == None: # This is a border case where the last cabfile had the exact space requiered for the last file. prev_cab = self.cab_files[-2] cab_file.cfheader.szCabinetPrev = CABFile.get_null_ended_string(prev_cab.cab_filename) cab_file.cfheader.szDiskPrev = CABFile.get_null_ended_string("previous") folder_list = cab_file.cfheader.cffolder_list for folder in folder_list: for _cffile in folder.cffile_list: if _cffile.szName == CABFile.get_null_ended_string(filename): if _cffile.iFolder in CFFILE.get_iFolder_options(): _cffile.iFolder |= CFFILE.ifoldCONTINUED_FROM_PREV else: _cffile.iFolder = CFFILE.ifoldCONTINUED_FROM_PREV # Update offsets - We need to do this every time # because we've just added some strings into the structure cab_file.update_fields()