<commit_before>package;


import sys.io.Process;
import sys.FileSystem;


class PathHelper {
	
	
	public static function combine (firstPath:String, secondPath:String):String {
		
		if (firstPath == null || firstPath == "") {
			
			if (secondPath != null && secondPath.substr (0, 1) == "/" || secondPath.substr (0, 1) == "\\") {
				
				return secondPath.substr (1);
				
			} else {
				
				return secondPath;
				
			}
			
		} else if (secondPath != null && secondPath != "") {
			
			var firstSlash = (firstPath.substr (-1) == "/" || firstPath.substr (-1) == "\\");
			var secondSlash = (secondPath.substr (0, 1) == "/" || secondPath.substr (0, 1) == "\\");
			
			if (firstSlash && secondSlash) {
				
				return firstPath + secondPath.substr (1);
				
			} else if (!firstSlash && !secondSlash) {
				
				return firstPath + "/" + secondPath;
				
			} else {
				
				return firstPath + secondPath;
				
			}
			
		} else {
			
			return firstPath;
			
		}
		
	}
	
	
	public static function escape (path:String):String {
		
		if (PlatformHelper.hostPlatform != Platform.WINDOWS) {
			
			path = StringTools.replace (path, " ", "\\ ");
			
			return expand (path);
			
		}
		
		return expand (path);
		
	}
	
	
	public static function expand (path:String):String {
		
		if (PlatformHelper.hostPlatform != Platform.WINDOWS) {
			
			if (StringTools.startsWith (path, "~/")) {
				
				path = Sys.getEnv ("HOME") + "/" + path.substr (2);
				
			}
			
		}
		
		return path;
		
	}
	
	
	public static function findTemplate (templatePaths:Array <String>, path:String, warnIfNotFound:Bool = true):String {
		
		var matches = findTemplates (templatePaths, path, warnIfNotFound);
		
		if (matches.length > 0) {
			
			return matches[matches.length - 1];
			
		}
		
		return null;<commit_msg>Minor tool fix for BlackBerry<commit_after>package;


import sys.io.Process;
import sys.FileSystem;


class PathHelper {
	
	
	public static function combine (firstPath:String, secondPath:String):String {
		
		if (firstPath == null || firstPath == "") {
			
			if (secondPath != null && secondPath.substr (0, 1) == "/" || secondPath.substr (0, 1) == "\\") {
				
				return secondPath.substr (1);
				
			} else {
				
				return secondPath;
				
			}
			
		} else if (secondPath != null && secondPath != "") {
			
			var firstSlash = (firstPath.substr (-1) == "/" || firstPath.substr (-1) == "\\");
			var secondSlash = (secondPath.substr (0, 1) == "/" || secondPath.substr (0, 1) == "\\");
			
			if (firstSlash && secondSlash) {
				
				return firstPath + secondPath.substr (1);
				
			} else if (!firstSlash && !secondSlash) {
				
				return firstPath + "/" + secondPath;
				
			} else {
				
				return firstPath + secondPath;
				
			}
			
		} else {
			
			return firstPath;
			
		}
		
	}
	
	
	public static function escape (path:String):String {
		
		if (PlatformHelper.hostPlatform != Platform.WINDOWS) {
			
			path = StringTools.replace (path, " ", "\\ ");
			
			return expand (path);
			
		}
		
		return expand (path);
		
	}
	
	
	public static function expand (path:String):String {
		
		if (path == null) {
			
			path = "";
			
		}
		
		if (PlatformHelper.hostPlatform != Platform.WINDOWS) {
			
			if (StringTools.startsWith (path, "~/")) {
				
				path = Sys.getEnv ("HOME") + "/" + path.substr (2);
				
			}
			
		}
		
		return path;
		
	}
	
	
	public static function findTemplate (templatePaths:Array <String>, path:String, warnIfNotFound:Bool = true):String {
		
		var matches = findTemplates (templatePaths, path, warnIfNotFound);
		
		if (matches.length > 0) {
			
			return matches[matches.length - 1];
			
		}
		
		return null;
{'fraction_non_alphanumeric': 0.14814814814814814, 'fraction_numerical': 0.00823045267489712, 'mean_word_length': 2.3884758364312266, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '2616843', 'n_tokens_mistral': 1544, 'n_tokens_neox': 1114, 'n_words': 267}