<commit_before>/*
   Copyright 2014-2019 Zumero, LLC

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

// Copyright © Microsoft Open Technologies, Inc.
// All Rights Reserved
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 
// http://www.apache.org/licenses/LICENSE-2.0
// 
// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
// 
// See the Apache 2 License for the specific language governing permissions and limitations under the License.

using System;
using System.IO;
using System.Collections.Generic;
using System.Runtime.InteropServices;

namespace SQLitePCL
{
	enum LibSuffix
	{
		DLL,
		DYLIB,
		SO,
	}

	enum Loader
	{
		win,
		dlopen,
	}

	public static class Setup
	{
		static string basename_to_libname(string basename, LibSuffix suffix)
		{
			switch (suffix)
			{
				case LibSuffix.DLL:
					return string.Format("{0}.dll", basename);
				case LibSuffix.DYLIB:
					return string.Format("lib{0}.dylib", basename);
				case LibSuffix.SO:
					return string.Format("lib{0}.so", basename);
				default:
					throw new NotImplementedException();
			}
		}

		static bool TryLoad(string name, Loader plat, out IGetFunctionPointer gf)
		{
			if (plat == Loader.win)
			{
				if (NativeLib_Win.try_Load(name, out var api))
				{
					gf = api;
					return true;
				}
				else
				{
					gf = null;
					return false;
				}
			}
			else if (plat == Loader.dlopen)
			{
				if (NativeLib_dlopen.try_Load(name, out var api))
				{
					gf = api;
					return true;
				}
				else
				{
					gf = null;
					return false;
				}
			}
			else
			{
				throw new NotImplementedException();
			}
		}

		static Loader WhichLoader()
		{
			if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
			{
				return Loader.win;
			}
			else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
			{
				return Loader.dlopen;
			}
			else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
			{
				return Loader.dlopen;
			}
			else
			{
				throw new NotImplementedException();
			}
		}

		static LibSuffix WhichLibSuffix()
		{
			if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
			{
				return LibSuffix.DLL;
			}
			else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
			{
				return LibSuffix.SO;
			}
			else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
			{
				return LibSuffix.DYLIB;
			}
			else
			{
				throw new NotImplementedException();
			}
		}

		static bool Search(
			IList<string> a, 
			Loader plat, 
			out string name,
			out IGetFunctionPointer gf
			)
		{
			foreach (var s in a)
			{
				if (TryLoad(s, plat, out var api))
				{
					name = s;
					gf = api;
					return true;
				}
			}
			name = null;
			gf = null;
			return false;
		}

		static List<string> MakePossibilitiesFor(
			string basename,
			LibSuffix suffix
			)
		{
			var a = new List<string>();

#if not
			a.Add(basename);
#endif

			var libname = basename_to_libname(basename, suffix);
			a.Add(libname);

#if not // TODO GetCurrentDirectory is in netstandard 1.3
			var cwd = System.IO.Directory.GetCurrentDirectory();
#endif

#if not // TODO GetExecutingAssembly is only in netstandard 2.0
			var dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
#endif

			// TODO add other names and paths, depending on platform

			return a;
		}<commit_msg>testing hack for finding dll<commit_after>/*
   Copyright 2014-2019 Zumero, LLC

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

// Copyright © Microsoft Open Technologies, Inc.
// All Rights Reserved
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 
// http://www.apache.org/licenses/LICENSE-2.0
// 
// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
// 
// See the Apache 2 License for the specific language governing permissions and limitations under the License.

using System;
using System.IO;
using System.Collections.Generic;
using System.Runtime.InteropServices;

namespace SQLitePCL
{
	enum LibSuffix
	{
		DLL,
		DYLIB,
		SO,
	}

	enum Loader
	{
		win,
		dlopen,
	}

	public static class Setup
	{
		static string basename_to_libname(string basename, LibSuffix suffix)
		{
			switch (suffix)
			{
				case LibSuffix.DLL:
					return string.Format("{0}.dll", basename);
				case LibSuffix.DYLIB:
					return string.Format("lib{0}.dylib", basename);
				case LibSuffix.SO:
					return string.Format("lib{0}.so", basename);
				default:
					throw new NotImplementedException();
			}
		}

		static bool TryLoad(string name, Loader plat, out IGetFunctionPointer gf)
		{
			if (plat == Loader.win)
			{
				if (NativeLib_Win.try_Load(name, out var api))
				{
					gf = api;
					return true;
				}
				else
				{
					gf = null;
					return false;
				}
			}
			else if (plat == Loader.dlopen)
			{
				if (NativeLib_dlopen.try_Load(name, out var api))
				{
					gf = api;
					return true;
				}
				else
				{
					gf = null;
					return false;
				}
			}
			else
			{
				throw new NotImplementedException();
			}
		}

		static Loader WhichLoader()
		{
			if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
			{
				return Loader.win;
			}
			else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
			{
				return Loader.dlopen;
			}
			else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
			{
				return Loader.dlopen;
			}
			else
			{
				throw new NotImplementedException();
			}
		}

		static LibSuffix WhichLibSuffix()
		{
			if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
			{
				return LibSuffix.DLL;
			}
			else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
			{
				return LibSuffix.SO;
			}
			else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
			{
				return LibSuffix.DYLIB;
			}
			else
			{
				throw new NotImplementedException();
			}
		}

		static bool Search(
			IList<string> a, 
			Loader plat, 
			out string name,
			out IGetFunctionPointer gf
			)
		{
			foreach (var s in a)
			{
				if (TryLoad(s, plat, out var api))
				{
					name = s;
					gf = api;
					return true;
				}
			}
			name = null;
			gf = null;
			return false;
		}

		static List<string> MakePossibilitiesFor(
			string basename,
			LibSuffix suffix
			)
		{
			var a = new List<string>();

#if not
			a.Add(basename);
#endif

			var libname = basename_to_libname(basename, suffix);
			a.Add(libname);

			// TODO a hack for testing.  works relative to cwd.
			a.Add(Path.Combine("runtimes", "win-x64", "native", libname));

#if not // TODO GetCurrentDirectory is in netstandard 1.3
			var cwd = System.IO.Directory.GetCurrentDirectory();
#endif

#if not // TODO GetExecutingAssembly is only in netstandard 2.0
			var dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
#endif

			// TODO add other names and paths, depending on platform

			return a;
		}
{'fraction_non_alphanumeric': 0.09144682361291849, 'fraction_numerical': 0.0059150597421033955, 'mean_word_length': 2.910268270120259, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2735950', 'n_tokens_mistral': 3295, 'n_tokens_neox': 2635, 'n_words': 835}