Exemple #1
0
    public static void BuildVersions(string outputPath, string[] bundles, int version)
    {
        var path = outputPath + "/" + Filename;

        if (File.Exists(path))
        {
            File.Delete(path);
        }

        var dataPath = outputPath + "/" + Dataname;

        if (File.Exists(dataPath))
        {
            File.Delete(dataPath);
        }

        var disk = new VDisk();

        foreach (var file in bundles)
        {
            using (var fs = File.OpenRead(outputPath + "/" + file))
            {
                disk.AddFile(file, fs.Length, Utility.GetCRC32Hash(fs));
            }
        }

        disk.name = dataPath;
        disk.Save();

        using (var stream = File.OpenWrite(path))
        {
            var writer = new BinaryWriter(stream);
            writer.Write(version);
            writer.Write(disk.files.Count + 1);
            using (var fs = File.OpenRead(dataPath))
            {
                var file = new VFile {
                    name = Dataname, len = fs.Length, hash = Utility.GetCRC32Hash(fs)
                };
                file.Serialize(writer);
            }
            foreach (var file in disk.files)
            {
                file.Serialize(writer);
            }
        }
    }
Exemple #2
0
        public Program(string[] args)
        {
            _consoleLock            = new object();
            LogProvider.OnLogWrite += LogProviderOnOnLogWrite;
            LogProvider.Start();

            if (args.Length <= 0)
            {
                return;
            }

            if (args[0] == "server")
            {
                KrPatchServer patchServer = new KrPatchServer();
                patchServer.Start();

                Setting      setting    = new Setting();
                KrGameServer gameServer = new KrGameServer(setting);
                gameServer.Start();
                while (Console.ReadKey().Key != ConsoleKey.E)
                {
                    Thread.Sleep(300);
                }

                gameServer.Stop();
            }

            if (args.Length >= 3 && args[0] == "vdisk-extract")
            {
                VDisk vDisk = new VDisk();
                vDisk.Open(args[1]);
                vDisk.Extract(args[2]);
            }

            if (args.Length >= 3 && args[0] == "vdisk-extract-all")
            {
                DirectoryInfo sourceFolder      = new DirectoryInfo(args[1]);
                DirectoryInfo destinationFolder = new DirectoryInfo(args[2]);

                FileInfo[] files = sourceFolder.GetFiles("*.SNP", SearchOption.AllDirectories);
                foreach (FileInfo file in files)
                {
                    VDisk vDisk = new VDisk();
                    vDisk.Open(file.FullName);
                    vDisk.Extract(destinationFolder.FullName);
                }
            }

            if (args.Length >= 4 && args[0] == "vdisk-archive")
            {
                VDisk vDisk = new VDisk();
                vDisk.AddFolder(args[1], args[2]);
                vDisk.Save(args[3]);
            }

            if (args.Length >= 2 && args[0] == "vdisk-test")
            {
                VDisk vDisk = new VDisk();
                vDisk.Open(args[1]);
                vDisk.Save(args[2]);
            }

            LogProvider.Stop();
            Console.WriteLine("Program Closed");
        }