Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.43 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using ICSharpCode.SharpZipLib.BZip2;
  6. using System.IO;
  7.  
  8. namespace BZ2
  9. {
  10.     class Program
  11.     {
  12.         static string rootdir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
  13.         static string outdir = @"C:\bz2\";
  14.        static int level = 9; //1 lowest 9 highest
  15.  
  16.        static string[] types = { ".bsp", ".vtf" };
  17.  
  18.        static void Main(string[] args)
  19.        {
  20.            try
  21.            {
  22.                if (args.Length == 1)
  23.                    rootdir = args[0];
  24.  
  25.                if (args.Length == 2)
  26.                {
  27.                    rootdir = args[0];
  28.                    outdir = args[1];
  29.                }
  30.  
  31.                if (args.Length == 3)
  32.                    level = int.Parse(args[2]);
  33.  
  34.                if (!rootdir.EndsWith(@"\"))
  35.                    rootdir += @"\";
  36.  
  37.                if (!outdir.EndsWith(@"\"))
  38.                    outdir += @"\";
  39.  
  40.                if (!Directory.Exists(outdir))
  41.                    Directory.CreateDirectory(outdir);
  42.  
  43.                Console.WriteLine("Using " + rootdir + " as root directory and " + outdir + " as output directory");
  44.  
  45.                Recurse(rootdir);
  46.  
  47.                Console.WriteLine("Done.");
  48.            }
  49.            catch (Exception e)
  50.            {
  51.                Console.WriteLine(e.Message);
  52.                Console.WriteLine(e.StackTrace);
  53.            }
  54.  
  55.            Console.ReadLine();
  56.        }
  57.  
  58.        static void Recurse(string dir)
  59.        {
  60.            string[] indirs = Directory.GetDirectories(dir); //HOW THE BLOODY FUCK DO I DO ALL SHIT ESIFJESIJFSEJFio
  61.  
  62.            foreach (string d in indirs)
  63.            {
  64.                string path = Path.Combine(outdir, Path.GetPathRoot(d), Path.GetFileNameWithoutExtension(d));
  65.                Console.WriteLine(path);
  66.  
  67.                //if (!Directory.Exists(path)) Directory.CreateDirectory(path);
  68.  
  69.                //string[] files = Directory.GetFiles(d);
  70.  
  71.                /*foreach (string f in files)
  72.                {
  73.                    if (!types.Contains(Path.GetExtension(f)))
  74.                        continue;
  75.                    string wpath = Path.Combine(path, Path.GetFileName(f) + ".bz2");
  76.                    Console.WriteLine(wpath);
  77.                    BZip2.Compress(File.OpenRead(f), File.Create(wpath), false, level);
  78.                }*/
  79.  
  80.                Recurse(d);
  81.            }
  82.        }
  83.    }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement