Nexus.Client.Games.Gamebryo.PluginManagement.Sorter.PluginSorter.CreateSorterDb C# (CSharp) Method

CreateSorterDb() private method

Creates the LOOT DB.
Explicitly manage database lifetime. Allows clients to free memory when they want/need to. This function also checks that plugins.txt and loadorder.txt (if they both exist) are in sync.
Thrown if the LOOT DB could not be created.
private CreateSorterDb ( ) : IntPtr
return System.IntPtr
		private IntPtr CreateSorterDb()
		{
			IntPtr ptrSorterDb = IntPtr.Zero;
			UInt32 uintClientGameId = 0;
			switch (GameMode.ModeId)
			{
				case "Oblivion":
					uintClientGameId = 1;
					break;
				case "Fallout3":
					uintClientGameId = 3;
					break;
				case "FalloutNV":
					uintClientGameId = 4;
					break;
				case "Skyrim":
					uintClientGameId = 2;
					break;
				default:
					throw new SorterException(String.Format("Unsupported game: {0} ({1})", GameMode.Name, GameMode.ModeId));
			}

			Backup();

			UInt32 uintStatus = m_dlgCreateDb(ref ptrSorterDb, uintClientGameId, GameMode.InstallationPath, null);

			//if ((uintStatus == 1) && (ptrSorterDb == IntPtr.Zero))
			//{
			//	string strGameModeLocalAppData = Path.Combine(Environment.GetEnvironmentVariable("LocalAppData"), GameMode.ModeId);
			//	string strLoadOrderFilePath = Path.Combine(strGameModeLocalAppData, "loadorder.txt");

			//	if (File.Exists(strLoadOrderFilePath))
			//	{
			//		string strBakFilePath = Path.Combine(strGameModeLocalAppData, "loadorder.nmmbak");
			//		if (File.Exists(strBakFilePath))
			//		{
			//			FileUtil.Move(strBakFilePath, Path.Combine(strGameModeLocalAppData, Path.GetRandomFileName() + ".loadorder.bak"), true);
			//		}

			//		FileUtil.Move(strLoadOrderFilePath, strBakFilePath, true);

			//		uintStatus = m_dlgCreateDb(ref ptrSorterDb, uintClientGameId, GameMode.InstallationPath, null);
			//	}
			//}

			//HandleStatusCode(uintStatus);
			//if (ptrSorterDb == IntPtr.Zero)
			//	throw new SorterException("Could not create LOOT DB.");
			return ptrSorterDb;
		}