Example #1
0
        public static void Main(string[] args)
        {
            string strOutFile;
            string strSolutionFile;
            MainOpts optObj = new MainOpts();
            ZipCompressor zcObj = new ZipCompressor();
            int i;

            // Handle command line arguments
            optObj.ProcessArgs(args);

            // Hangle no parameters being passed
            if(args.Length < 1 || optObj.SolutionFile.Length < 1)
            {
                optObj.DoHelp();
                return;
            }

            // Check for BlackListed Extensions being passed
            if(optObj.Extensions.Length > 0)
            {
                g_strBlacListedFiles = optObj.Extensions;
            }

            // Check for BlackListed directories being passed
            if(optObj.BlacListedDirectories.Length > 0)
            {
                g_strBlacListedDirectories = optObj.BlacListedDirectories;
            }

            strSolutionFile = optObj.SolutionFile;

            if(optObj.OutputFilePath.Length > 0)
            {
                strOutFile = optObj.OutputFilePath;
            }
            else
            {
                strOutFile =
                    Path.Combine(
                    Path.GetDirectoryName(strSolutionFile),
                    (Path.GetFileNameWithoutExtension(strSolutionFile) + ".zip")
                    );
            }

            if(System.IO.Path.GetExtension(strSolutionFile).ToUpper().CompareTo(".SLN") != 0)
            {
                Console.WriteLine("The file you submited does not seem like a Visual Studio .NET Solution file.");
                return;
            }

            // Parse solution
            Drive.ParseSolution(strSolutionFile);

            // build a string array of the base solution directory
            // and the projects directory
            string []straBaseDirs = new string[g_straDirList.Count];
            for(i = 0; i < straBaseDirs.Length; i++)
            {
                straBaseDirs[i] = (string)g_straDirList[i];
                AddFilesToFileList(straBaseDirs[i]);
            }

            // Clear the global Directory ArrayList
            g_straDirList.Clear();

            // Build the File ArrayList
            string []straFilenames = new string[g_straFileList.Count];
            for(i = 0; i < straFilenames.Length; i++)
            {
                straFilenames[i] = (string)g_straFileList[i];
            }

            // Clear the global File ArrayList
            g_straFileList.Clear();

            // Invoke the Programs main functionality and purpose
            zcObj.CompressionLevel = optObj.Level;
            zcObj.CreateZipFile(straFilenames, strOutFile);
        }
Example #2
0
        public static void Main(string[] args)
        {
            string        strOutFile;
            string        strSolutionFile;
            MainOpts      optObj = new MainOpts();
            ZipCompressor zcObj  = new ZipCompressor();
            int           i;

            // Handle command line arguments
            optObj.ProcessArgs(args);

            // Hangle no parameters being passed
            if (args.Length < 1 || optObj.SolutionFile.Length < 1)
            {
                optObj.DoHelp();
                return;
            }

            // Check for BlackListed Extensions being passed
            if (optObj.Extensions.Length > 0)
            {
                g_strBlacListedFiles = optObj.Extensions;
            }

            // Check for BlackListed directories being passed
            if (optObj.BlacListedDirectories.Length > 0)
            {
                g_strBlacListedDirectories = optObj.BlacListedDirectories;
            }

            strSolutionFile = optObj.SolutionFile;

            if (optObj.OutputFilePath.Length > 0)
            {
                strOutFile = optObj.OutputFilePath;
            }
            else
            {
                strOutFile =
                    Path.Combine(
                        Path.GetDirectoryName(strSolutionFile),
                        (Path.GetFileNameWithoutExtension(strSolutionFile) + ".zip")
                        );
            }

            if (System.IO.Path.GetExtension(strSolutionFile).ToUpper().CompareTo(".SLN") != 0)
            {
                Console.WriteLine("The file you submited does not seem like a Visual Studio .NET Solution file.");
                return;
            }

            // Parse solution
            Drive.ParseSolution(strSolutionFile);

            // build a string array of the base solution directory
            // and the projects directory
            string [] straBaseDirs = new string[g_straDirList.Count];
            for (i = 0; i < straBaseDirs.Length; i++)
            {
                straBaseDirs[i] = (string)g_straDirList[i];
                AddFilesToFileList(straBaseDirs[i]);
            }

            // Clear the global Directory ArrayList
            g_straDirList.Clear();

            // Build the File ArrayList
            string [] straFilenames = new string[g_straFileList.Count];
            for (i = 0; i < straFilenames.Length; i++)
            {
                straFilenames[i] = (string)g_straFileList[i];
            }

            // Clear the global File ArrayList
            g_straFileList.Clear();

            // Invoke the Programs main functionality and purpose
            zcObj.CompressionLevel = optObj.Level;
            zcObj.CreateZipFile(straFilenames, strOutFile);
        }