Beispiel #1
0
        static void Main(string[] args)
        {
            string Path   = System.IO.Directory.GetCurrentDirectory();
            string Target = System.IO.Directory.GetCurrentDirectory() + "\\FastDL";

            if (System.IO.Directory.Exists(Target))
            {
                System.IO.Directory.Delete(Target, true);
            }

            FileManager FM = new FileManager(Path);
            string      NewFile;
            int         Depth;
            int         cnt = 0;

            foreach (File file in FM.Files)
            {
                if (Ignore(file.Ext) || !file.IsWithinDirectory("addons"))
                {
                    continue;
                }

                NewFile = "";
                Depth   = 0;

                foreach (string folder in file.Path)
                {
                    if (Depth == 0 && folder.ToLower() == "addons")
                    {
                        Depth++;
                        continue;
                    }
                    else if (Depth == 1)
                    {
                        Depth++;
                    }
                    else if (Depth == 2)
                    {
                        NewFile += folder + "/";
                    }
                }

                Console.Out.WriteLine(Target + NewFile + file.Name + file.Ext + " -> " + file.GetFullPath());
                FM.Copy(Target + "\\" + NewFile + file.Name + file.Ext, file.GetFullPath());
                FM.Compress(Target + "\\" + NewFile + file.Name + file.Ext);
                cnt++;
            }

            System.Console.Out.WriteLine("\nDONE! " + cnt + " files copied and compressed!");
            System.Console.In.ReadLine();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            string Path = System.IO.Directory.GetCurrentDirectory();
            string Target = System.IO.Directory.GetCurrentDirectory() + "\\FastDL";

            if (System.IO.Directory.Exists(Target))
                System.IO.Directory.Delete(Target, true);

            FileManager FM = new FileManager(Path);
            string NewFile;
            int Depth;
            int cnt = 0;

            foreach(File file in FM.Files)
            {
                if (Ignore(file.Ext) || !file.IsWithinDirectory("addons"))
                    continue;

                NewFile = "";
                Depth = 0;

                foreach (string folder in file.Path)
                {
                    if (Depth == 0 && folder.ToLower() == "addons")
                    {
                        Depth++;
                        continue;
                    }
                    else if (Depth == 1)
                    {
                        Depth++;
                    }
                    else if (Depth==2)
                    {
                        NewFile += folder+"/";
                    }
                }

                Console.Out.WriteLine(Target + NewFile + file.Name + file.Ext + " -> " + file.GetFullPath());
                FM.Copy(Target + "\\" + NewFile + file.Name + file.Ext, file.GetFullPath());
                FM.Compress(Target + "\\" + NewFile + file.Name + file.Ext);
                cnt++;
            }

            System.Console.Out.WriteLine("\nDONE! "+cnt+" files copied and compressed!");
            System.Console.In.ReadLine();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Usage: <addons path>");
                Console.ReadLine();
                return;
            }

            string path = args[0].Replace("\"", "");

            if (!Directory.Exists(path))
            {
                Console.WriteLine("Invalid Directory: " + path);
                Console.ReadLine();
                return;
            }

            string target = Directory.GetCurrentDirectory() + @"\" + (new DirectoryInfo(path).Name) + "_out";

            if (Directory.Exists(target))
            {
                Directory.Delete(target, true);
            }

            Directory.CreateDirectory(target + @"\lua\autorun\server\");

            StreamWriter rf = new StreamWriter(target + @"\lua\autorun\server\resource_" + Math.Floor((DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds) + ".lua");
            FileManager  fm = new FileManager(path);
            FileInfo     fi;
            int          total     = 0;
            int          useless   = 0;
            long         ignorelen = 0;
            long         beforelen = 0;
            long         afterlen  = 0;

            foreach (File file in fm.Files)
            {
                if (!IsValidFile(file.Ext))
                {
                    continue;
                }

                string relitivepath = "";
                foreach (string folder in file.Path)
                {
                    if (IsValidDir(folder))
                    {
                        break;
                    }

                    relitivepath = relitivepath + @"\" + folder;
                }

                string fullpath = file.GetFullPath();
                relitivepath = fullpath.Replace(relitivepath.Substring(1), "");
                string nicepath = relitivepath.Substring(1).Replace(@"\", "/");

                if ((fullpath.Substring(fullpath.Length - 9) == ".xbox.vtx") || (fullpath.Substring(fullpath.Length - 7) == ".sw.vtx"))
                {
                    Console.WriteLine("Ignored -> " + nicepath);
                    fi         = new FileInfo(fullpath);
                    ignorelen += fi.Length;
                    useless++;
                    continue;
                }

                if (file.Ext != ".bsp")
                {
                    rf.WriteLine("resource.AddSingleFile'" + nicepath + "'");
                }

                fm.Copy(target + relitivepath, fullpath);

                fi         = new FileInfo(target + relitivepath);
                beforelen += fi.Length;

                Console.WriteLine("Copied -> " + nicepath);

                fm.Compress(target + relitivepath);

                fi        = new FileInfo(target + relitivepath + ".bz2");
                afterlen += fi.Length;

                Console.WriteLine("Compressed -> " + nicepath + ".bz2");

                total++;
            }

            rf.Close();

            Console.WriteLine("\n\nComplete:");
            Console.WriteLine("   Files Compressed: " + total);
            Console.WriteLine("   Files Ignored: " + useless);
            Console.WriteLine("   Uncompressed Size: " + beforelen / 1024 / 1024 + "mb");
            Console.WriteLine("   Compressed Size: " + afterlen / 1024 / 1024 + "mb");
            Console.WriteLine("   Total Saved: " + ((ignorelen + beforelen) - afterlen) / 1024 / 1024 + "mb");
            Console.ReadLine();
        }