Example #1
0
 public static string[] GetFiles(CabinetOpenCabHandler openCabHandler, CabinetCloseCabHandler closeCabHandler,
                                 object openCabContext, bool autoChain)
 {
     using (CabExtractor cabInstance = new CabExtractor())
     {
         cabInstance.openCabHandler  = openCabHandler;
         cabInstance.closeCabHandler = closeCabHandler;
         cabInstance.openCabContext  = openCabContext;
         cabInstance.nextCabinetName = "";
         cabInstance.listFiles       = new ArrayList();
         for (short iCab = 0; (autoChain || iCab == 0) && cabInstance.nextCabinetName != null; iCab++)
         {
             cabInstance.cabNumbers[""] = iCab;
             cabInstance.Process();
         }
                 #if !CABMINIMAL
         string[] fileNames = new string[cabInstance.listFiles.Count];
         for (int i = 0; i < cabInstance.listFiles.Count; i++)
         {
             fileNames[i] = ((CabinetFileInfo)cabInstance.listFiles[i]).Name;
         }
         return(fileNames);
                 #else
         return((string[])cabInstance.listFiles.ToArray(typeof(string)));
                 #endif
     }
 }
Example #2
0
        public static void Extract(CabinetOpenCabHandler openCabHandler, CabinetCloseCabHandler closeCabHandler,
                                   object openCabContext, bool autoChain, CabinetExtractOpenFileHandler openFileHandler,
                                   CabinetExtractCloseFileHandler closeFileHandler, object openFileContext,
                                   CabinetFilterFileHandler filterFileHandler, object filterContext,
                                   CabinetStatusCallback statusCallback, object statusContext)
        #endif // !CABMINIMAL
        {
            using (CabExtractor cabInstance = new CabExtractor())
            {
                cabInstance.openCabHandler    = openCabHandler;
                cabInstance.closeCabHandler   = closeCabHandler;
                cabInstance.openCabContext    = openCabContext;
                cabInstance.openFileHandler   = openFileHandler;
                cabInstance.closeFileHandler  = closeFileHandler;
                cabInstance.openFileContext   = openFileContext;
                cabInstance.filterFileHandler = filterFileHandler;
                cabInstance.filterFileContext = filterContext;
                cabInstance.fdiNotifyHandler  = new FDI.PFNNOTIFY(cabInstance.CabExtractNotify);
                cabInstance.nextCabinetName   = "";

                        #if !CABMINIMAL
                cabInstance.statusCallback = statusCallback;
                cabInstance.statusContext  = statusContext;

                if (statusCallback != null)
                {
                    CabinetFileInfo[] files = Cabinet.GetFiles(openCabHandler, closeCabHandler, openCabContext,
                                                               autoChain, filterFileHandler, filterContext);

                    cabInstance.status.totalFiles     = files.Length;
                    cabInstance.status.totalFileBytes = 0;

                    int prevFolder = -1, prevCabinet = -1;
                    for (int i = 0; i < files.Length; i++)
                    {
                        cabInstance.status.totalFileBytes += files[i].Length;
                        if (files[i].CabinetFolderNumber != prevFolder)                 // Assumes the results of GetFiles are grouped by folders
                        {
                            prevFolder = files[i].CabinetFolderNumber;
                            cabInstance.status.totalFolders++;
                        }
                        if (files[i].CabinetNumber != prevCabinet)
                        {
                            prevCabinet = files[i].CabinetNumber;
                            cabInstance.status.totalCabinets++;
                        }
                    }
                }
                        #endif // !CABMINIMAL

                for (short iCab = 0; (autoChain || iCab == 0) && cabInstance.nextCabinetName != null; iCab++)
                {
                    cabInstance.cabNumbers[""] = iCab;
                    cabInstance.Process();
                }
            }
        }
Example #3
0
 internal static CabinetFileInfo[] GetFiles(CabinetOpenCabHandler openCabHandler, CabinetCloseCabHandler closeCabHandler,
                                            object openCabContext, bool autoChain, CabinetFilterFileHandler filterFileHandler, object filterContext)
 {
     using (CabExtractor cabInstance = new CabExtractor())
     {
         cabInstance.filterFileHandler = filterFileHandler;
         cabInstance.filterFileContext = filterContext;
         cabInstance.openCabHandler    = openCabHandler;
         cabInstance.closeCabHandler   = closeCabHandler;
         cabInstance.openCabContext    = openCabContext;
         cabInstance.nextCabinetName   = "";
         cabInstance.listFiles         = new ArrayList();
         for (short iCab = 0; (autoChain || iCab == 0) && cabInstance.nextCabinetName != null; iCab++)
         {
             cabInstance.cabNumbers[""] = iCab;
             cabInstance.Process();
         }
         return((CabinetFileInfo[])cabInstance.listFiles.ToArray(typeof(CabinetFileInfo)));
     }
 }