<commit_before>using System.Collections;
using System.Collections.Generic;
using UnityEngine;


//	gr: PopX being renamed to Pop later
namespace PopX
{
	public static class IO
	{
		static public string	Application_ProjectPath	{	get { return Application.dataPath.Split (new string[]{ "/Assets" }, System.StringSplitOptions.None) [0]; } }

		public static void WriteStringToFile (string Filename, string Data)
		{
			var FileHandle = System.IO.File.CreateText( Filename );
			FileHandle.Write(Data);
			FileHandle.Close();
		}


		//	throw if not project relative
		public static string GetProjectRelativePath(string Path)
		{
			//	gr: this seems to always return an empty string...
			//UnityEditor.FileUtil.GetProjectRelativePath (Path);

			if (string.IsNullOrEmpty (Path))
				return Path;

			var ProjectPath = Application_ProjectPath;

			if (!Path.StartsWith (ProjectPath))
				throw new System.Exception ("Path " + Path + " is not project relative (" + ProjectPath + ")");

			Path = Path.Remove (0, ProjectPath.Length);
			return Path;
		}

	}
}
<commit_msg>Adding simple PopX.IO.SaveFile call to do all the file-saving stuff and callback a lambda<commit_after>using System.Collections;
using System.Collections.Generic;
using UnityEngine;


//	gr: PopX being renamed to Pop later
namespace PopX
{
	public static class IO
	{
		//	file types we can write/export
		//	gr: value used as extension (todo; support multiple extensions per type, eg. jpeg and jpg)
		public enum ImageFileType
		{
			png,
			jpg,
			exr
		};

		static public string Application_ProjectPath { get { return Application.dataPath.Split(new string[] { "/Assets" }, System.StringSplitOptions.None)[0]; } }

		public static void WriteStringToFile(string Filename, string Data)
		{
			var FileHandle = System.IO.File.CreateText(Filename);
			FileHandle.Write(Data);
			FileHandle.Close();
		}


		//	throw if not project relative
		public static string GetProjectRelativePath(string Path)
		{
			//	gr: this seems to always return an empty string...
			//UnityEditor.FileUtil.GetProjectRelativePath (Path);

			if (string.IsNullOrEmpty(Path))
				return Path;

			var ProjectPath = Application_ProjectPath;

			if (!Path.StartsWith(ProjectPath))
				throw new System.Exception("Path " + Path + " is not project relative (" + ProjectPath + ")");

			Path = Path.Remove(0, ProjectPath.Length);
			return Path;
		}

#if UNITY_EDITOR
		public static void SaveFile(string DefaultName, ImageFileType Extension, System.Action<string, ImageFileType> DoSave)
		{
			var ExtensionsString = Extension.ToString();
			var DefaultDirectory = Application.dataPath;

			var Filename = UnityEditor.EditorUtility.SaveFilePanel("Save as...", DefaultDirectory, DefaultName, ExtensionsString);
			if (string.IsNullOrEmpty(Filename))
				throw new System.Exception("Save cancelled");

			/*	gr: might still want this on windows if the user can choose a different extension. osx won't allow it
			//	get the full path
			//	work out the extension used
			ImageFileType? Extension = null;
			foreach (var Ext in Extensions)
				if (Filename.EndsWith(Ext.ToString()))
					Extension = Ext;
			if (!Extension.HasValue)
				throw new System.Exception("Couldn't determine file extension selected by user");
			*/

			DoSave(Filename, Extension);
		}
		#endif
	}
}

{'fraction_non_alphanumeric': 0.10057384475989127, 'fraction_numerical': 0.0012080942313500453, 'mean_word_length': 3.8421052631578947, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2285551', 'n_tokens_mistral': 1084, 'n_tokens_neox': 942, 'n_words': 302}