Exemplo n.º 1
0
        public static RootDirectoryEntity CreateRootEntityFromDirectory(string path, bool withHash = true, IProgress <int> progress = null)
        {
            DirectoryInfo       wot  = new DirectoryInfo(path);
            RootDirectoryEntity root = new RootDirectoryEntity(GetGameVersion(path));
            HashProvider        hp   = withHash ? new SHA1HashProvider() : null;

            GameDirectoryParser.Parse(wot, root, wot.FullName.Length, hp, IgnoreList.FromEnumerable(File.ReadAllLines("ignored.txt")), progress);
            return(root);
        }
Exemplo n.º 2
0
        private async void btnShowInfo_Click(object sender, RoutedEventArgs e)
        {
            btnShowInfo.IsEnabled = false;
            string              gameDir     = txtFolder.Text;
            DirectoryInfo       gameDirInfo = new DirectoryInfo(gameDir);
            string              version     = Helpers.GetGameVersion(gameDir);
            RootDirectoryEntity root        = new RootDirectoryEntity(version);
            await Task.Run(() => GameDirectoryParser.Parse(gameDirInfo, root, gameDirInfo.FullName.Length, null, new IgnoreList(), null));

            long   files  = Helpers.TotalFiles(root);
            long   size   = Helpers.TotalSize(root) / (1024 * 1024);
            string result = string.Format("Directory: {0}\nVersion: {1}\nTotal files: {2:N0}\nTotal size: {3:N0} MB", gameDir, version, files, size);

            MessageBox.Show(result);
            btnShowInfo.IsEnabled = true;
        }
        private async void btnCreateFile_Click(object sender, RoutedEventArgs e)
        {
            DirectoryInfo       wot    = new DirectoryInfo(txtGameFolder.Text);
            string              output = txtOutputFile.Text;
            RootDirectoryEntity root   = new RootDirectoryEntity(Helpers.GetGameVersion(txtGameFolder.Text));
            HashProvider        sha1   = new SHA1HashProvider();

            btnCreateFile.IsEnabled = false;
            btnCreateFile.Content   = "Creating...";
            await Task.Run(() => GameDirectoryParser.Parse(wot, root, wot.FullName.Length, sha1, IgnoreList.FromEnumerable(File.ReadAllLines("ignored.txt")), null));

            await Task.Run(() => new RootDirectoryEntityIO().Serialize(root, output));

            btnCreateFile.Content   = "Create";
            btnCreateFile.IsEnabled = true;
        }