<commit_before>package utils;

import FlxTools.IDE;
import haxe.Json;
import massive.sys.io.File as MassiveFile;
import massive.sys.io.FileSys;
import sys.FileSystem;
import sys.io.File;
import sys.io.Process;

/**
 * Utilities for command line tools
 */
class CommandUtils
{
	/**
	 * Copy a directory and its contents recursively
	 * @param  source	  String the source directory to copy
	 * @param  destination String to destination to copy the directory to
	 * @param  overwrite  Overwrite the destination
	 * @return	Bool true if the new Destination exists after operation
	 */
	public static function copyRecursively(source:String, destination:String, overwrite:Bool = true, ?filter:EReg, exclude:Bool = false):Bool
	{
		final source = MassiveFile.create(source);
		final destination = MassiveFile.create(destination, true);

		source.copyTo(destination, overwrite, filter, exclude);

		return destination.exists;
	}

	public static function deleteRecursively(path:String)
	{
		if (FileSys.exists(path))
		{
			if (FileSys.isDirectory(path))
			{
				for (entry in FileSys.readDirectory(path))
				{
					deleteRecursively(path + "/" + entry);
				}
				FileSys.deleteDirectory(path);
			}
			else
			{
				FileSys.deleteFile(path);
			}
		}
	}<commit_msg>Fix project and template creation on Windows when Haxelib repository path uses forward slashes<commit_after>package utils;

import FlxTools.IDE;
import haxe.Json;
import massive.sys.io.File as MassiveFile;
import massive.sys.io.FileSys;
import sys.FileSystem;
import sys.io.File;
import sys.io.Process;

/**
 * Utilities for command line tools
 */
class CommandUtils
{
	/**
	 * Copy a directory and its contents recursively
	 * @param  source	  String the source directory to copy
	 * @param  destination String to destination to copy the directory to
	 * @param  overwrite  Overwrite the destination
	 * @return	Bool true if the new Destination exists after operation
	 */
	public static function copyRecursively(source:String, destination:String, overwrite:Bool = true, ?filter:EReg, exclude:Bool = false):Bool
	{
		// Windows can deal with forward slashes, but mlib thinks it can't be an absolute path
		// if there are no backslashes (see https://github.com/massiveinteractive/mlib/issues/13)
		if (Sys.systemName() == "Windows")
		{
			source = source.replace("/", "\\");
			destination = destination.replace("/", "\\");
		}

		final source = MassiveFile.create(source);
		final destination = MassiveFile.create(destination, true);

		source.copyTo(destination, overwrite, filter, exclude);

		return destination.exists;
	}

	public static function deleteRecursively(path:String)
	{
		if (FileSys.exists(path))
		{
			if (FileSys.isDirectory(path))
			{
				for (entry in FileSys.readDirectory(path))
				{
					deleteRecursively(path + "/" + entry);
				}
				FileSys.deleteDirectory(path);
			}
			else
			{
				FileSys.deleteFile(path);
			}
		}
	}
{'fraction_non_alphanumeric': 0.10459533607681756, 'fraction_numerical': 0.0006858710562414266, 'mean_word_length': 3.9524617996604414, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '7526021', 'n_tokens_mistral': 975, 'n_tokens_neox': 860, 'n_words': 252}