Example #1
0
        //0- Original File Name
        //1- Original File Size
        //2- First Part Name
        //3- Parts Number
        //4- {
        //   P% Name
        //   P% Size
        //   }
        private void GenerateSfx()
        {
            if (!includeSfx)
            {
                return;
            }

            Header hdr = new Header();

            //Self Joiner Signature
            hdr.Add(Path.GetFileName(fileName));
            hdr.Add(fileSize.ToString());
            hdr.Add(Path.GetFileName(files[0]));
            hdr.Add(files.Count.ToString());

            for (int i = 0; i < files.Count; i++)
            {
                hdr.Add(Path.GetFileName(files[i]));
                hdr.Add(pSizes[i].ToString());
            }

            if (Sfx.OutPath.Length > 0)
            {
                hdr.Add(Sfx.OutPath);
            }
            else
            {
                hdr.Add("\0");
            }

            if (Sfx.Comment.Length > 0)
            {
                hdr.Add(Sfx.Comment);
            }
            else
            {
                hdr.Add("\0");
            }

            string sfxPath = Path.Combine(outputFolder, "Q Join.exe");

            File.Copy(Path.Combine(Application.StartupPath, "qj.bin"), sfxPath, true);
            long sfxSize = IoTools.GetFileSize(sfxPath);

            FileStream   fs = new FileStream(sfxPath, FileMode.Append);
            BinaryWriter br = new BinaryWriter(fs);

            br.Seek(0, SeekOrigin.End);
            hdr.Write(br);

            fs.Close();
            br.Close();

            fs.Dispose();
        }
Example #2
0
        private void GetSplitterInfo()
        {
            info.FileSize = IoTools.GetFileSize(fileName);

            if (segmentSize == 0)
            {
                return;
            }

            info.SegmentSize = segmentSize;
            info.Segments    = (int)(info.FileSize / segmentSize + 0.5f);

            UpdateSegments();
        }
Example #3
0
        public static bool LoadParts(FrmBase frm)
        {
            string fileName = GetFirstPart();

            if (fileName == null)
            {
                frm.ShowMessage("Invalid source file name, Can not find first part.", MsgType.Error);
                return(false);
            }

            string pDir = Directory.GetParent(txtFileName.Text).FullName;

            OutFileName = Path.Combine(pDir, fileName);

            string fName = fileName + ".1.qsx"; //First part
            string fPath = Path.Combine(pDir, fName);

            partSize = IoTools.GetFileSize(fPath);

            if (partSize == 0)
            {
                frm.ShowMessage("File Access Denied, file is being used by another process.", MsgType.Error);
                return(false);
            }

            Header hdr = new Header();

            if (!File.Exists(fPath))
            {
                frm.ShowMessage("Source file: '" + fPath + "' does not exists.", MsgType.Error);
                return(false);
            }

            if (IoTools.FileOpened(fPath))
            {
                frm.ShowMessage("File Access Denied, file is being used by another process.", MsgType.Error);
                return(false);
            }

            if (hdr.ReadHeader(fPath))
            {
                int      pNum  = int.Parse(hdr.HeaderBlock.Rows[0]); //Parts number
                string[] files = new string[pNum];
                for (int i = 0; i < pNum; i++)
                {
                    string cFile = Path.Combine(pDir, hdr.HeaderBlock.Rows[i + 1]);
                    if (File.Exists(cFile))
                    {
                        files[i] = cFile;
                    }
                    else
                    {
                        //File 'cFile' Does not exists
                        frm.ShowMessage("Source file: '" + cFile + "' is missing.", MsgType.Error);
                        return(false);
                    }
                }

                Joiner.FileNames = files;

                if (hdr.HeaderBlock.Rows.Count > pNum + 1)
                {
                    Joiner.OutputSize = long.Parse(hdr.HeaderBlock.Rows[pNum + 1]);
                }
            }
            else
            {
                frm.ShowMessage("'" + fPath + "' is not a valid source file.", MsgType.Error);
                return(false);
            }

            return(true);
        }