+ def __generic_find_heads (self, regex, ignorecase=True):
+
+ heads = []
+
+ if ignorecase:
+ cregex = re.compile (regex, re.IGNORECASE)
+ else:
+ cregex = re.compile (regex)
+
+ all_files = no_duplicates (self.name_matched_files + self.prot_matched_files)
+
+ for f in all_files:
+ if cregex.match (f):
+ heads.append (f)
+
+ return heads
+
+ def __find_heads (self):
+
+ if self.type == TYPE_OLDRAR:
+ return self.__generic_find_heads ('^.*\.rar$')
+ elif self.type == TYPE_NEWRAR:
+ return self.__generic_find_heads ('^.*\.part0*1\.rar$')
+ elif self.type == TYPE_ZIP:
+ return self.__generic_find_heads ('^.*\.zip$')
+ elif self.type == TYPE_NOEXTRACT:
+ return self.prot_matched_files
+
+ return []
+
+ def __create_directory (self, dir):
+ if dir == None:
+ return SUCCESS
+
+ if os.path.isdir (dir):
+ return SUCCESS
+
+ try:
+ os.makedirs (dir)
+ logger.addMessage ('Created directory: %s' % dir, RarslaveLogger.MessageType.Verbose)
+ except OSError:
+ logger.addMessage ('FAILED to create directory: %s' % dir, RarslaveLogger.MessageType.Fatal)
+ return -EEXTRACT
+
+ return SUCCESS
+
+ def runExtract (self, todir=None):