コード例 #1
0
        public FileDownloader(IWoWRepository repository, List <FileObject> files)
        {
            Files    = files;
            BasePath = repository.GetDefaultDirectory();

            Progress = new ConsoleDownloadProgressBar(Files.Count);
        }
コード例 #2
0
        public static ManifestFile FromRepository(IWoWRepository repository)
        {
            try
            {
                var manifest = new ManifestFile();
                var client = new WebClient();

                string content = client.DownloadString(repository.GetBaseUrl() + repository.GetMFilName());

                string[] lines = content.Split('\n');

                foreach (string line in lines)
                {
                    if (line.Trim().StartsWith("version="))
                    {
                        int output;
                        if (int.TryParse(line.Trim().Replace("version=", ""), out output))
                        {
                            manifest.Version = output;
                        }
                    }
                    manifest.Lines.Add(line.Trim().Replace("file=", repository.GetBaseUrl()));
                }

                return manifest;
            }
            catch (Exception ex)
            {
                Program.Log("Unable to retrieve Manifest file", ConsoleColor.Red);
                Program.Log(ex.Message, ConsoleColor.Red);
            }
            return null;
        }
コード例 #3
0
        public FileDownloader(IWoWRepository repository, List<FileObject> files)
        {
            Files = files;
            BasePath = repository.GetDefaultDirectory();

            Progress = new ConsoleDownloadProgressBar(Files.Count);
        }
コード例 #4
0
        public List <FileObject> GenerateFileList()
        {
            IWoWRepository repository = RepositoriesManager.GetRepositoryByMfil(WoWRegeneration.CurrentSession.MFil);

            var tmp = new List <FileObject>();

            foreach (string line in Lines)
            {
                if (IsLineARepositorFile(repository, line))
                {
                    var file = new FileObject {
                        Path = GetFilePath(line)
                    };
                    if (file.Path == null)
                    {
                        continue;
                    }
                    file.Url  = line;
                    file.Info = GetFileInfo(repository, line);
                    if (IsAcceptedFile(repository, file))
                    {
                        tmp.Add(file);
                    }
                }
            }

            return(tmp);
        }
コード例 #5
0
        public static ManifestFile FromRepository(IWoWRepository repository)
        {
            try
            {
                var manifest = new ManifestFile();
                var client   = new WebClient();

                string content = client.DownloadString(repository.GetBaseUrl() + repository.GetMFilName());

                string[] lines = content.Split('\n');

                foreach (string line in lines)
                {
                    if (line.Trim().StartsWith("version="))
                    {
                        int output;
                        if (int.TryParse(line.Trim().Replace("version=", ""), out output))
                        {
                            manifest.Version = output;
                        }
                    }
                    manifest.Lines.Add(line.Trim().Replace("file=", repository.GetBaseUrl()));
                }

                return(manifest);
            }
            catch (Exception ex)
            {
                Program.Log("Unable to retrieve Manifest file", ConsoleColor.Red);
                Program.Log(ex.Message, ConsoleColor.Red);
            }
            return(null);
        }
コード例 #6
0
        private static void EntryPointResumeSession(Session previousSession)
        {
            CurrentSession = previousSession;

            IWoWRepository repository = RepositoriesManager.GetRepositoryByMfil(CurrentSession.MFil);
            ManifestFile   manifest   = ManifestFile.FromRepository(repository);

            CurrentSession.SaveSession();

            StartProcess(manifest);
        }
コード例 #7
0
 private bool IsLineARepositorFile(IWoWRepository repository, string line)
 {
     if (line.StartsWith(repository.GetBaseUrl()))
     {
         if (line.Substring(line.Length - 4, 1) == ".")
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #8
0
        private static void EntryPointNewSession()
        {
            IWoWRepository repository = UserInputs.SelectRepository();
            ManifestFile   manifest   = ManifestFile.FromRepository(repository);
            string         locale     = UserInputs.SelectLocale(manifest);
            string         os         = UserInputs.SelectOs();

            CurrentSession = new Session(repository.GetMFilName(), locale, os);
            CurrentSession.SaveSession();

            StartProcess(manifest);
        }
コード例 #9
0
        private static void StartProcess(ManifestFile manifest)
        {
            Program.Log("Generating file list");
            IWoWRepository    repository = RepositoriesManager.GetRepositoryByMfil(CurrentSession.MFil);
            List <FileObject> files      = manifest.GenerateFileList();

            var downloader = new FileDownloader(repository, files);

            downloader.Start();
            CurrentSession.SessionCompleted = true;
            CurrentSession.SaveSession();
            CurrentSession.Destroy();
            Program.Log("Download Complete !!", ConsoleColor.Green);
        }
コード例 #10
0
ファイル: Session.cs プロジェクト: aikonlee/wowregeneration
        public Session(string mfil, string locale, string os)
            : this()
        {
            MFil   = mfil;
            Locale = locale;
            Os     = os;
            IWoWRepository rep = RepositoriesManager.GetRepositoryByMfil(mfil);

            if (rep == null)
            {
                throw new Exception("Unknow mfil file");
            }
            WoWRepositoryName = rep.GetVersionName();
        }
コード例 #11
0
        private bool IsAcceptedFile(IWoWRepository repository, FileObject file)
        {
            if (WoWRegeneration.CurrentSession.Os == "Win" && file.Filename == "base-OSX.MPQ")
            {
                return(false);
            }

            if (WoWRegeneration.CurrentSession.Os == "OSX" && file.Filename == "base-Win.MPQ")
            {
                return(false);
            }

            if (file.Filename == "alternate.MPQ" && file.Info != WoWRegeneration.CurrentSession.Locale)
            {
                return(false);
            }

            if (WoWRegeneration.CurrentSession.CompletedFiles.Contains(file.Path) &&
                File.Exists(Program.ExecutionPath + repository.GetDefaultDirectory() + file.Path))
            {
                Program.Log("Skipping " + file.Filename + " allready downloaded", ConsoleColor.DarkGray);
                return(false);
            }

            if (WoWRegeneration.CurrentSession.CompletedFiles.Contains(file.Path))
            {
                WoWRegeneration.CurrentSession.CompletedFiles.Remove(file.Path);
                WoWRegeneration.CurrentSession.SaveSession();
            }

            if (file.Directory == "Data/")
            {
                return(true);
            }

            if (file.Directory.StartsWith("Data/Interface/"))
            {
                return(true);
            }

            if (file.Directory.StartsWith("Data/" + WoWRegeneration.CurrentSession.Locale))
            {
                return(true);
            }
            return(false);
        }
コード例 #12
0
        private string GetFileInfo(IWoWRepository repository, string line)
        {
            int index = Lines.IndexOf(line);

            for (int n = 1; n <= 5; n++)
            {
                string next = Lines[index + n];
                if (IsLineARepositorFile(repository, next))
                {
                    return(null);
                }
                if (next.StartsWith("path=locale_"))
                {
                    return(next.Replace("path=locale_", ""));
                }
            }
            return(null);
        }
コード例 #13
0
 private bool IsLineARepositorFile(IWoWRepository repository, string line)
 {
     if (line.StartsWith(repository.GetBaseUrl()))
     {
         if (line.Substring(line.Length - 4, 1) == ".")
         {
             return true;
         }
     }
     return false;
 }
コード例 #14
0
        private bool IsAcceptedFile(IWoWRepository repository, FileObject file)
        {
            if (WoWRegeneration.CurrentSession.Os == "Win" && file.Filename == "base-OSX.MPQ")
                return false;

            if (WoWRegeneration.CurrentSession.Os == "OSX" && file.Filename == "base-Win.MPQ")
                return false;

            if (file.Filename == "alternate.MPQ" && file.Info != WoWRegeneration.CurrentSession.Locale)
                return false;

            if (WoWRegeneration.CurrentSession.CompletedFiles.Contains(file.Path) &&
                File.Exists(Program.ExecutionPath + repository.GetDefaultDirectory() + file.Path))
            {
                Program.Log("Skipping " + file.Filename + " allready downloaded", ConsoleColor.DarkGray);
                return false;
            }

            if (WoWRegeneration.CurrentSession.CompletedFiles.Contains(file.Path))
            {
                WoWRegeneration.CurrentSession.CompletedFiles.Remove(file.Path);
                WoWRegeneration.CurrentSession.SaveSession();
            }

            if (file.Directory == "Data/")
            {
                return true;
            }

            if (file.Directory.StartsWith("Data/Interface/"))
            {
                return true;
            }

            if (file.Directory.StartsWith("Data/" + WoWRegeneration.CurrentSession.Locale))
            {
                return true;
            }
            return false;
        }
コード例 #15
0
 private string GetFileInfo(IWoWRepository repository, string line)
 {
     int index = Lines.IndexOf(line);
     for (int n = 1; n <= 5; n++)
     {
         string next = Lines[index + n];
         if (IsLineARepositorFile(repository, next))
             return null;
         if (next.StartsWith("path=locale_"))
             return next.Replace("path=locale_", "");
     }
     return null;
 }