@@ -7921,9 +7921,20 @@ def PackFoxFileFromInFile(infile, outfile, fmttype="auto", compression="auto", c
79217921 return False
79227922 return False
79237923
7924- # --- Add this helper (Py2/3 compatible) ---
7925- def FoxFileArrayValidate (listarrayfiles , verbose = False ):
7926- # Top-level checks
7924+ def FoxFileArrayValidate (infile , verbose = False ):
7925+ # ---------- Input handling ----------
7926+ if isinstance (infile , dict ):
7927+ listarrayfileslist = [infile ]
7928+ elif isinstance (infile , list ):
7929+ listarrayfileslist = infile
7930+ else :
7931+ if (infile != "-" and not isinstance (infile , (bytes , bytearray , memoryview )) # bytes is str on Py2
7932+ and not hasattr (infile , "read" ) and not hasattr (infile , "write" )):
7933+ infile = RemoveWindowsPath (infile )
7934+ listarrayfileslist = ArchiveFileToArray (
7935+ infile , fmttype , filestart , 0 , 0 ,
7936+ False , True , False , True , formatspecs , saltkey , seektoend , returnfp
7937+ )
79277938 if not isinstance (listarrayfiles , dict ):
79287939 if verbose : logging .warning ("listarrayfiles must be a dict, got %r" , type (listarrayfiles ))
79297940 return False
@@ -7935,53 +7946,53 @@ def FoxFileArrayValidate(listarrayfiles, verbose=False):
79357946 if verbose : logging .warning ("ffilelist must be a list, got %r" , type (listarrayfiles ["ffilelist" ]))
79367947 return False
79377948
7938- # Per-entry required keys
7939- required = [
7940- "fname" , "fencoding" , "fheadersize" , "fsize" , "flinkname" ,
7941- "fatime" , "fmtime" , "fctime" , "fbtime" ,
7942- "fmode" , "fchmode" , "fuid" , "funame" , "fgid" , "fgname" ,
7943- "finode" , "flinkcount" , "fwinattributes" ,
7944- "fcompression" , "fcsize" ,
7945- "fdev" , "fminor" , "fmajor" ,
7946- "fseeknextfile" , "fextradata" , "fextrafields" ,
7947- "fcontents" , "fcontentasfile" , "fjsondata" , "ftype" ,
7948- ]
7949- ok = True
7950- for i , ent in enumerate (listarrayfiles ["ffilelist" ]):
7951- if not isinstance (ent , dict ):
7952- if verbose : logging .warning ("ffilelist[%d] must be a dict, got %r" , i , type (ent ))
7953- ok = False
7954- continue
7955- missing = [k for k in required if k not in ent ]
7956- if missing :
7957- if verbose : logging .warning ("ffilelist[%d] missing keys: %s" , i , ", " .join (missing ))
7958- ok = False
7959- continue
7960- # Light type/convert checks for numeric-ish fields
7961- intish = [
7962- "fheadersize" , "fsize" , "fatime" , "fmtime" , "fctime" , "fbtime" ,
7963- "fmode" , "fchmode" , "fuid" , "fgid" , "finode" ,
7964- "flinkcount" , "fwinattributes" , "fcsize" ,
7965- "fdev" , "fminor" , "fmajor" , "ftype" ,
7949+ for listarrayfiles in listarrayfileslist :
7950+ # Per-entry required keys
7951+ required = [
7952+ "fname" , "fencoding" , "fheadersize" , "fsize" , "flinkname" ,
7953+ "fatime" , "fmtime" , "fctime" , "fbtime" ,
7954+ "fmode" , "fchmode" , "fuid" , "funame" , "fgid" , "fgname" ,
7955+ "finode" , "flinkcount" , "fwinattributes" ,
7956+ "fcompression" , "fcsize" , "fdev" , "frdev" ,
7957+ "fseeknextfile" , "fextradata" , "fextrafields" ,
7958+ "fcontents" , "fcontentasfile" , "fjsondata" , "ftype" ,
79667959 ]
7967- for k in intish :
7968- try :
7969- int (ent [k ])
7970- except Exception :
7971- if verbose : logging .warning ("ffilelist[%d].%s expected int-convertible, got %r" , i , k , ent [k ])
7960+ ok = True
7961+ for i , ent in enumerate (listarrayfiles ["ffilelist" ]):
7962+ if not isinstance (ent , dict ):
7963+ if verbose : logging .warning ("ffilelist[%d] must be a dict, got %r" , i , type (ent ))
7964+ ok = False
7965+ continue
7966+ missing = [k for k in required if k not in ent ]
7967+ if missing :
7968+ if verbose : logging .warning ("ffilelist[%d] missing keys: %s" , i , ", " .join (missing ))
7969+ ok = False
7970+ continue
7971+ # Light type/convert checks for numeric-ish fields
7972+ intish = [
7973+ "fheadersize" , "fsize" , "fatime" , "fmtime" , "fctime" , "fbtime" ,
7974+ "fmode" , "fchmode" , "fuid" , "fgid" , "finode" ,
7975+ "flinkcount" , "fwinattributes" , "fcsize" ,
7976+ "fdev" , "frdev" , "ftype" ,
7977+ ]
7978+ for k in intish :
7979+ try :
7980+ int (ent [k ])
7981+ except Exception :
7982+ if verbose : logging .warning ("ffilelist[%d].%s expected int-convertible, got %r" , i , k , ent [k ])
7983+ ok = False
7984+ # Booleans/flags presence
7985+ if not isinstance (ent ["fcontentasfile" ], (bool , int )): # tolerate 0/1
7986+ if verbose : logging .warning ("ffilelist[%d].fcontentasfile should be bool-like, got %r" , i , ent ["fcontentasfile" ])
79727987 ok = False
7973- # Booleans/flags presence
7974- if not isinstance (ent ["fcontentasfile" ], (bool , int )): # tolerate 0/1
7975- if verbose : logging .warning ("ffilelist[%d].fcontentasfile should be bool-like, got %r" , i , ent ["fcontentasfile" ])
7976- ok = False
7977- # Arrays presence
7978- for arrk in ("fextradata" ,):
7979- if not isinstance (ent [arrk ], list ):
7980- if verbose : logging .warning ("ffilelist[%d].%s should be a list, got %r" , i , arrk , type (ent [arrk ]))
7988+ # Arrays presence
7989+ for arrk in ("fextradata" ,):
7990+ if not isinstance (ent [arrk ], list ):
7991+ if verbose : logging .warning ("ffilelist[%d].%s should be a list, got %r" , i , arrk , type (ent [arrk ]))
7992+ ok = False
7993+ if not isinstance (ent .get ("fjsondata" , {}), dict ):
7994+ if verbose : logging .warning ("ffilelist[%d].fjsondata should be a dict, got %r" , i , type (ent .get ("fjsondata" )))
79817995 ok = False
7982- if not isinstance (ent .get ("fjsondata" , {}), dict ):
7983- if verbose : logging .warning ("ffilelist[%d].fjsondata should be a dict, got %r" , i , type (ent .get ("fjsondata" )))
7984- ok = False
79857996 return ok
79867997
79877998 # ---------- Input handling ----------
0 commit comments