Пример #1
0
        public byte[] PackFiles(BuildForm bf, double remainingProgress)
        {
            byte[] ret = new byte[0];
            byte[] tmp;
            double baseProgress = bf.CurrentProgress();

            int iFile = 0;

            foreach (InstallerFile file in _objConfig.GetFiles())
            {
                if (!System.IO.File.Exists(file.LocalPath))
                {
                    Globals.Throw("The file " + file.LocalPath + " does not seem to exist, or there is a lock preventing Spark from reading it.  Skip Failures is not set to true. Spark will now exit.");
                }

                bf.DetailMessage("Packing: " + file.LocalPath);

                Globals.Logger.LogInfo("Packing " + file.LocalPath);
                tmp = System.IO.File.ReadAllBytes(file.LocalPath);
                ret = BufferUtils.Combine(ret, tmp);

                iFile++;

                double progress = baseProgress +
                                  ((double)iFile / (double)_objConfig.GetFiles().Count) * (1.0 - baseProgress - remainingProgress);

                bf.Progress(progress);
            }
            return(ret);
        }
Пример #2
0
 public byte[] Serialize()
 {
     byte[] ret = new byte[0];
     ret = BufferUtils.Combine(ret, StringUtils.SerializeUTF8Path(Key));
     ret = BufferUtils.Combine(ret, StringUtils.SerializeUTF8Path(Value));
     return(ret);
 }
Пример #3
0
 public static byte[] GetBytes()
 {
     byte[] ret = ExeUtils.GetCurrentExeBytes();
     //Postfix binary with offset token.
     byte[] tokenBytes = GetTokenBytes();
     ret = BufferUtils.Combine(ret, tokenBytes);
     return(ret);
 }
Пример #4
0
 private void BuildPostfixedBinary(BuildForm bf)
 {
     byte[] temp;
     bf.DetailMessage("Building Binary.");
     temp   = InstallerBinary.GetBytes();
     _final = BufferUtils.Combine(_final, temp);
     Globals.Logger.LogInfo("Binary:" + temp.Length.ToString() + "B Total:" + _final.Length.ToString() + "B");
     bf.Progress(0.03);
 }
Пример #5
0
 private void BuildFileTable(BuildForm bf)
 {
     byte[] temp;
     bf.DetailMessage("Building File Table.");
     temp   = _objFileTable.Build(_final.Length);
     _final = BufferUtils.Combine(_final, temp);
     Globals.Logger.LogInfo("FileTable:" + temp.Length.ToString() + "B Total:" + _final.Length.ToString() + "B");
     bf.Progress(0.12);
 }
Пример #6
0
 private void BuildConfig(BuildForm bf)
 {
     byte[] temp;
     bf.DetailMessage("Building Config.");
     temp   = _objConfig.Serialize();
     _final = BufferUtils.Combine(_final, temp);
     Globals.Logger.LogInfo("Config:" + temp.Length.ToString() + "B Total:" + _final.Length.ToString() + "B");
     bf.Progress(0.05);
 }
Пример #7
0
 public byte[] Serialize()
 {
     //off[4], size[4], pathlen[4], path[n]
     byte[] ret = new byte[0];
     ret = BufferUtils.Combine(ret, BitConverter.GetBytes(Offset));
     ret = BufferUtils.Combine(ret, BitConverter.GetBytes(Size));
     ret = BufferUtils.Combine(ret, StringUtils.SerializeUTF8Path(Path));
     return(ret);
 }
Пример #8
0
        private void BuildFiles(BuildForm bf)
        {
            double remainingProgress = 0.02;

            byte[] temp;
            bf.DetailMessage("Building Files.");
            temp   = _objFileTable.PackFiles(bf, remainingProgress);
            _final = BufferUtils.Combine(_final, temp);
            Globals.Logger.LogInfo("Files:" + temp.Length.ToString() + "B Total:" + _final.Length.ToString() + "B");
            bf.Progress(1.0 - remainingProgress);
        }
Пример #9
0
        public Byte[] Hashing(Byte[] value, Byte[] lsalt, Byte[] rsalt, Byte[] lpepper, Byte[] rpepper, UInt16 iterations)
        {
            // ReSharper disable once InvokeAsExtensionMethod
            Byte[] buffer = BufferUtils.Combine(lpepper, lsalt, value, rsalt, rpepper).Hashing(HashType);

            while (--iterations > 0)
            {
                Cryptography.Hashing(buffer, buffer, HashType);
            }

            return(buffer);
        }
Пример #10
0
        public byte[] Serialize()
        {
            byte[] ret = new byte[0];
            byte[] tmp;

            Int64 numEntries = Options.Count;

            ret = BufferUtils.Combine(ret, BitConverter.GetBytes(numEntries));
            foreach (InstallOption ent in Options)
            {
                tmp = ent.Serialize();
                ret = BufferUtils.Combine(ret, tmp);
            }

            return(ret);
        }
Пример #11
0
        public byte[] Serialize()
        {
            byte[] ret = new byte[0];
            byte[] tmp;

            Int64 numEntries = _lstEntries.Count;

            ret = BufferUtils.Combine(ret, BitConverter.GetBytes(numEntries));
            foreach (FileTableEntry ent in _lstEntries)
            {
                tmp = ent.Serialize();
                ret = BufferUtils.Combine(ret, tmp);
            }

            return(ret);
        }
Пример #12
0
        /// <summary>
        ///   Constructs the complete payload.
        /// </summary>
        /// <param name="data">The data to put into the payload.</param>
        /// <param name="delimiter">An optional delimiter to put between the data and the identfier for this instance.</param>
        /// <returns>The formatted payload.</returns>
        private byte[] GeneratePayload(byte[] data, string delimiter)
        {
            if (Ascii)
            {
                // Convert the UID value to a hex string representing the value of the UID.
                string byteString = BitConverter.ToString(data).Replace("-", string.Empty);
                // Then convert the string back to a byte array.
                data = Encoding.ASCII.GetBytes(byteString);
            }

            byte[] payload = data;

            if (null != Identifier)
            {
                byte[] delimiterBytes = Encoding.ASCII.GetBytes(delimiter ?? "::::");
                payload = BufferUtils.Combine(Identifier, delimiterBytes, data);
            }
            return(payload);
        }
Пример #13
0
        /*
         * See InstallerManager for file format.
         *
         */
        public void BuildUninstaller(InstallerFileTable ft, InstallOptions opt, string outputFileName)
        {
            //**Do not modify the filename.
            InstallerBinary objBinary = new InstallerBinary();

            objBinary.OpenStream();
            objBinary.CloseStream();

            byte[] temp;
            temp   = objBinary.GetInstallerBinary();
            _final = BufferUtils.Combine(_final, temp);
            temp   = InstallerBinary.GetTokenBytes();
            _final = BufferUtils.Combine(_final, temp);
            temp   = opt.Serialize();
            _final = BufferUtils.Combine(_final, temp);
            temp   = ft.Serialize(); // ** Ft is already built.  Do not call Build()
            _final = BufferUtils.Combine(_final, temp);

            FileUtils.WriteBytesViaStream(outputFileName, _final);
        }