<commit_before>//
//  FileManager.swift
//  Bedrock
//
//  Created by <NAME> on 6/15/15.
//  Copyright (c) 2015 Bedrock. All rights reserved.
//

import Darwin.POSIX.sys

struct FileManager {
	static func fileExists(path: String) -> Bool {
		/// Path length, even after symbolic link resolution, must never exceed PATH_MAX.
		let p = path.substringToIndex(advance(path.startIndex, Int(PATH_MAX))).fileSystemRepresentation()
		var st = stat()
		// Check for a symbolic link first.
		if lstat(p, &st) < 0 {
			return false
		}

		// Don't touch symlinks.  They will expand and do terrible things sometimes.
		if st.st_mode == S_IFLNK {
			return true
		}

		// Stat a real path.
		if stat(p, &st) < 0 {
			return false
		}

		return true
	}
}<commit_msg>Do directory stuff too<commit_after>//
//  FileManager.swift
//  Bedrock
//
//  Created by <NAME> on 6/15/15.
//  Copyright (c) 2015 Bedrock. All rights reserved.
//

import Darwin.POSIX.sys

struct FileManager {
	static func fileExists(path: String) -> (fileExists: Bool, isDirectory: Bool) {
		/// Path length, even after symbolic link resolution, must never exceed PATH_MAX.
		let p = path.substringToIndex(advance(path.startIndex, Int(PATH_MAX))).fileSystemRepresentation()
		var st = stat()
		// Check for a symbolic link first.
		if lstat(p, &st) < 0 {
			return (false, false)
		}

		// Don't touch symlinks.  They will expand and do terrible things sometimes.
		if st.st_mode == S_IFLNK {
			return (true, false)
		}

		// Stat a real path.
		if stat(p, &st) < 0 {
			return (false, false)
		}

		return (true, st.st_mode == S_IFDIR)
	}
}
{'fraction_non_alphanumeric': 0.1251564455569462, 'fraction_numerical': 0.01376720901126408, 'mean_word_length': 2.957920792079208, 'pattern_counts': {'":': 0, '<': 9, '<?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': '4117964', 'n_tokens_mistral': 618, 'n_tokens_neox': 537, 'n_words': 175}