Exemple #1
0
        private static void RetrieveKeyWithFind(string keyAsString)
        {
            Console.WriteLine(string.Format("Retrieveing '{0}' using Find() method:", keyAsString));

            using (CdbReader cdbReader = new CdbReader(cdbFilePath))
            {
                byte[] key   = EncodeKey(keyAsString);
                byte[] value = null;

                value = cdbReader.Find(key);

                DisplayValue(value);
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            /* Display a usage message if we didn't get the correct number
             * of arguments. */
            if (args.Length != 1)
            {
                Console.WriteLine("CDB Dumper: usage: ConstantDatabase.Dumper.exe file");
                return;
            }

            /* Decode our arguments. */
            string cdbFile = args[0];

            /* Dump the CDB file. */

            byte[] newLine           = Encoding.ASCII.GetBytes(Environment.NewLine);
            byte[] keyValueSeparator = { (byte)'-', (byte)'>' };
            Stream outStream         = Console.OpenStandardOutput();

            try
            {
                IEnumerator <CdbEntry> iter = CdbReader.Entries(cdbFile);
                while (iter.MoveNext())
                {
                    CdbEntry entry = iter.Current;

                    if (entry == null)
                    {
                        continue;
                    }

                    byte[] key  = entry.Key;
                    byte[] data = entry.Data;

                    byte[] buffer = Encoding.ASCII.GetBytes("+" + key.Length + "," + data.Length + ":");
                    outStream.Write(buffer, 0, buffer.Length);
                    outStream.Write(key, 0, key.Length);
                    outStream.Write(keyValueSeparator, 0, keyValueSeparator.Length);
                    outStream.Write(data, 0, data.Length);
                    outStream.Write(newLine, 0, newLine.Length);
                }

                outStream.Write(newLine, 0, newLine.Length);
            }
            catch (IOException ioException)
            {
                Console.WriteLine("Couldn't dump CDB file: " + ioException);
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            /* Display a usage message if we didn't get the correct number
             * of arguments. */
            if (args.Length < 2)
            {
                Console.WriteLine("CDB Maker: usage: ConstantDatabase.Maker.exe cdb_file temp_file [ignoreCdb]");
                return;
            }
            /* Decode our arguments. */
            string cdbFile  = args[0];
            string tempFile = args[1];

            /* Load the ignoreCdb if requested. */
            CdbReader ignoreCdb = null;

            if (args.Length > 3)
            {
                try
                {
                    ignoreCdb = new CdbReader(args[2]);
                }
                catch (IOException ioException)
                {
                    Console.WriteLine("Couldn't load `ignore' CDB file: " + ioException);
                }
            }

            /* Create the CDB file. */
            try
            {
                CdbWriter.Make(Console.OpenStandardInput(), cdbFile, tempFile, ignoreCdb);
            }
            catch (IOException ioException)
            {
                Console.WriteLine("Couldn't create CDB file: " + ioException);
            }
        }