<commit_before>/*
	This file is part of the Util library.
	Copyright (C) 2007-2014 <NAME> <<EMAIL>>
	
	This library is subject to the terms of the Mozilla Public License, v. 2.0.
	You should have received a copy of the MPL along with this library; see the 
	file LICENSE. If not, you can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "FileLocator.h"
#include "FileUtils.h"
#include "../StringUtils.h"

namespace Util {


std::pair<bool,FileName> FileLocator::locateFile(const FileName& relFile)const{
	if(FileUtils::isFile(relFile))
		return std::make_pair(true,relFile);
	
	const std::string relFilePath = relFile.getDir() + relFile.getFile(); // without file system file://
	for(const auto& path : searchPaths){
		const FileName fullPath( (path.empty() || path.back()=='/') ?  path+relFilePath : path+"/"+relFilePath);
		if(FileUtils::isFile(fullPath))
			return std::make_pair(true,fullPath);
	}
	
	return std::make_pair(false,FileName());
}


}<commit_msg>FileLocator: Use existing function FileLocator::findFile.<commit_after>/*
	This file is part of the Util library.
	Copyright (C) 2007-2014 <NAME> <<EMAIL>>
	
	This library is subject to the terms of the Mozilla Public License, v. 2.0.
	You should have received a copy of the MPL along with this library; see the 
	file LICENSE. If not, you can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "FileLocator.h"
#include "FileUtils.h"
#include "../StringUtils.h"

namespace Util {


std::pair<bool,FileName> FileLocator::locateFile(const FileName& relFile)const{
	if(FileUtils::isFile(relFile))
		return std::make_pair(true,relFile);
		
	FileName foundPath;
	if(	FileUtils::findFile(relFile,std::list<std::string>(searchPaths.begin(),searchPaths.end()),foundPath) )
		return std::make_pair(true,foundPath);

	return std::make_pair(false,FileName());
}


}
{'fraction_non_alphanumeric': 0.1412151067323481, 'fraction_numerical': 0.013136288998357963, 'mean_word_length': 5.033003300330033, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '7512762', 'n_tokens_mistral': 638, 'n_tokens_neox': 589, 'n_words': 173}