コード例 #1
0
        public void LoadUpdateList()
        {
            switch (OPT.GetInt("send.type"))
            {
            case 0:     // Google drive
                using (StreamReader sr = new StreamReader(File.Open(string.Format(@"{0}\{1}", Directory.GetCurrentDirectory(), "gIndex.opt"), FileMode.Open, FileAccess.Read)))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        string[] optBlocks = line.Split('|');
                        if (optBlocks.Length == 4)
                        {
                            UpdateIndex.Add(new IndexEntry {
                                FileName = optBlocks[0], SHA512 = optBlocks[1], Legacy = Convert.ToBoolean(Convert.ToInt32(optBlocks[2])), Delete = Convert.ToBoolean(Convert.ToInt32(optBlocks[3]))
                            });
                        }
                    }
                }
                break;

            case 1:     // HTTP
                break;

            case 2:     // FTP
                break;

            case 3:     // TCP
                foreach (string filePath in Directory.GetFiles(updatesDir))
                {
                    string fileName = Path.GetFileName(filePath);

                    UpdateIndex.Add(new IndexEntry
                    {
                        FileName = fileName,
                        SHA512   = Hash.GetSHA512Hash(filePath),
                        Legacy   = OPT.IsLegacy(fileName),
                        Delete   = OPT.IsDelete(fileName)
                    });
                }
                break;
            }
        }
コード例 #2
0
        public static void Build(bool rebuild)
        {
            if (rebuild && OPT.GetBool("debug"))
            {
                Console.Write("Rebuilding the Update Index...");
            }
            else
            {
                Console.Write("Building the Update Index...");
            }

            Program.Wait = true;

            if (Index.Count > 0)
            {
                Index.Clear();
            }

            switch (OPT.GetInt("send.type"))
            {
            case 0:     // Google drive
                using (StreamReader sr = new StreamReader(File.Open(string.Format(@"{0}\{1}", System.IO.Directory.GetCurrentDirectory(), "gIndex.opt"), FileMode.Open, FileAccess.Read)))
                {
                    //string line;
                    //while ((line = sr.ReadLine()) != null)
                    //{
                    //    string[] optBlocks = line.Split('|');
                    //    if (optBlocks.Length == 4)
                    //    {
                    //        Index.Add(new IndexEntry { FileName = optBlocks[0], SHA512 = optBlocks[1], Legacy = Convert.ToBoolean(Convert.ToInt32(optBlocks[2])), Delete = Convert.ToBoolean(Convert.ToInt32(optBlocks[3])) });
                    //    }
                    //}
                }
                break;

            case 1:     // HTTP
                break;

            case 2:     // FTP
                break;

            case 3:     // TCP
                foreach (string filePath in System.IO.Directory.GetFiles(UpdatesDirectory))
                {
                    string fileName = Path.GetFileName(filePath);

                    Index.Add(new IndexEntry
                    {
                        FileName = fileName,
                        SHA512   = Hash.GetSHA512Hash(filePath),
                        Legacy   = OPT.IsLegacy(fileName),
                        Delete   = OPT.IsDelete(fileName)
                    });
                }
                break;
            }

            if (rebuild && OPT.GetBool("debug"))
            {
                Console.WriteLine("[OK]\n\t{0} files indexed", Count);
            }
            else
            {
                Console.WriteLine("[OK]\n\t{0} files indexed", Count);
            }

            Program.Wait = false;
        }
コード例 #3
0
        public static void Build(bool rebuild)
        {
            Output.WriteAndLock(new Message()
            {
                Text = string.Format("{0} the Update Index...", (rebuild && OPT.GetBool("debug")) ? "Rebuilding" : "Building")
            });

            if (rebuild)
            {
                Program.Wait = true;
            }

            if (Index.Count > 0)
            {
                Index.Clear();
            }

            switch (OPT.GetInt("send.type"))
            {
            case 0:     // Google drive
                using (StreamReader sr = new StreamReader(File.Open(string.Format(@"{0}\{1}", System.IO.Directory.GetCurrentDirectory(), "gIndex.opt"), FileMode.Open, FileAccess.Read)))
                {
                    //string line;
                    //while ((line = sr.ReadLine()) != null)
                    //{
                    //    string[] optBlocks = line.Split('|');
                    //    if (optBlocks.Length == 4)
                    //    {
                    //        Index.Add(new IndexEntry { FileName = optBlocks[0], SHA512 = optBlocks[1], Legacy = Convert.ToBoolean(Convert.ToInt32(optBlocks[2])), Delete = Convert.ToBoolean(Convert.ToInt32(optBlocks[3])) });
                    //    }
                    //}
                }
                break;

            case 1:     // HTTP
                break;

            case 2:     // FTP
                break;

            case 3:     // TCP
                foreach (string filePath in System.IO.Directory.GetFiles(UpdatesDirectory))
                {
                    string fileName = Path.GetFileName(filePath);

                    Index.Add(new IndexEntry
                    {
                        FileName = fileName,
                        SHA512   = Hash.GetSHA512Hash(filePath),
                        Legacy   = OPT.IsLegacy(fileName),
                        Delete   = OPT.IsDelete(fileName)
                    });
                }
                break;
            }

            if (OPT.GetBool("debug"))
            {
                Output.WriteAndUnlock(new Message()
                {
                    Text = string.Format("[OK]\n\t- {0} files indexed", Count), AddBreak = true
                });
            }

            if (rebuild)
            {
                Program.Wait = false;
            }

            GUI.Instance.Invoke(new System.Windows.Forms.MethodInvoker(delegate {
                GUI.Instance.updatesViewBtn.Enabled = true;
                GUI.Instance.updatesView.Enabled    = true;
            }));
        }