Beispiel #1
0
 private static bool ExtractFiles(ref BinaryReader br, ref List <XisoTableData> list, Xisoftp.FTPSettingsData ftpOpts, XisoOptions xisoOpts)
 {
     _totalProcessed = 0;
     if (list.Count == 0)
     {
         return(false);
     }
     UpdateStatus("Connecting to server...");
     if (!Xisoftp.Connect(ftpOpts.Host, ftpOpts.Port, ftpOpts.DataConnectionType, ftpOpts.User, ftpOpts.Password))
     {
         UpdateStatus(string.Format("Connection failed! Last Error: {0}", Xisoftp.LastError));
         return(false);
     }
     if (!Xisoftp.SetDirectory(ftpOpts.Path))
     {
         UpdateStatus(string.Format("Set Directory Failure! Last Error: {0}", Xisoftp.LastError));
         Xisoftp.Disconnect();
         return(false);
     }
     UpdateStatus(string.Format("Creating Directory: {0}", xisoOpts.Target));
     if (!Xisoftp.CreateDirectory(xisoOpts.Target))
     {
         UpdateStatus(string.Format("Create target Directory Failure! Last Error: {0}", Xisoftp.LastError));
         Xisoftp.Disconnect();
         return(false);
     }
     ftpOpts.Path += xisoOpts.Target;
     UpdateStatus(string.Format("Extracting files to ftp:{0}", ftpOpts.Path));
     UpdateOperation(string.Format("Extracting files to ftp:{0}", ftpOpts.Path));
     foreach (var entry in list)
     {
         if (entry.IsFile)
         {
             continue;
         }
         var dir = ftpOpts.Path + (entry.Path.Substring(1) + entry.Name).Replace("\\", "/");
         UpdateStatus(string.Format("Creating Directory: {0}", dir));
         Xisoftp.CreateDirectory(dir);
     }
     foreach (var entry in list)
     {
         if (Abort)
         {
             return(false);
         }
         if (!entry.IsFile)
         {
             continue;
         }
         if (!Xisoftp.SetDirectory((ftpOpts.Path + entry.Path.Replace("\\", "/")).Replace("//", "/")))
         {
             UpdateStatus(string.Format("Set Directory Failure! Last Error: {0}", Xisoftp.LastError));
             Xisoftp.Disconnect();
             return(false);
         }
         UpdateStatus(string.Format("Extracting {0}{1} ({2})", entry.Path, entry.Name, Utils.GetSizeReadable(entry.Size)));
         if (!Xisoftp.SendFile(entry.Name, ref br, entry.Offset, entry.Size, xisoOpts, entry.Path))
         {
             UpdateStatus(string.Format("Send File Failure! Last Error: {0}", Xisoftp.LastError));
             Xisoftp.Disconnect();
             return(false);
         }
     }
     if (xisoOpts.GenerateSfv)
     {
         xisoOpts.SfvGen.Save();
     }
     return(true);
 }