Пример #1
0
 private static void InitKeyValueStore()
 {
     try
     {
         if (File.Exists("services.dat") && File.Exists("services.tree"))
         {
             _tree = BplusTree.ReOpen("services.tree", "services.dat");
         }
         else
         {
             _tree = BplusTree.Initialize("services.tree", "services.dat", 36);
         }
     }
     catch (Exception)
     {
         Log.Error("Error initialising service tree");
         //_tree = BplusTree.Initialize("services.tree", "services.dat", 36);
     }
 }
Пример #2
0
        private void OpenSaveFile(string filename, string path)
        {
            if (IsOpen())
            {
                Debug.LogError(
                    $"You are trying to open an already opened save file ('{filename}')");
                return;
            }

            var treeFileName  = Path.Combine(path, filename + ".save");
            var blockFileName = Path.Combine(path, filename + ".block");

            try
            {
                _tree = BplusTree.Initialize(treeFileName, blockFileName, 40);
            }
            catch (IOException)
            {
                try
                {
                    _tree = BplusTree.ReOpen(treeFileName, blockFileName);
                }
                catch (DirectoryNotFoundException e)
                {
                    Debug.LogError(
                        "Error while opening the save file, check that the specified directory exists\n" +
                        e);
                    return;
                }
                catch (IOException e)
                {
                    Debug.LogError(
                        $"Error while opening the save file, check that save file '{filename}' is not already open\n" +
                        e);
                    return;
                }
            }

            _open     = true;
            _filename = filename;
            _path     = path;
        }