# This file is part of shellfire core. It is subject to the licence terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/shellfire-dev/core/master/COPYRIGHT. No part of shellfire core, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
# Copyright © 2014-2015 The developers of shellfire core. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/shellfire-dev/core/master/COPYRIGHT.


core_path_isReadableFilePath()
{
	local filePath="$1"
	
	if [ ! -e "$filePath" ]; then
		return 1
	fi
	
	if [ ! -f "$filePath" ]; then
		return 1
	fi
	
	if [ -r "$filePath" ]; then
		return 0
	fi
	
	return 1
}

core_path_isReadableNonEmptyFilePath()
{
	local filePath="$1"
	
	core_path_isReadableFilePath "$filePath"
	
	if [ -s "$filePath" ]; then
		return 0
	fi
	
	return 1
}

core_path_isReadableNonEmptyExecutableFilePath()
{
	local filePath="$1"
	
	core_path_isReadableNonEmptyFilePath "$filePath"
	
	if [ -x "$filePath" ]; then
		return 0
	fi
	
	return 1
}

core_path_isReadableAndSearchableFolderPath()
{
	local folderPath="$1"
	
	if [ ! -e "$folderPath" ]; then
		return 1
	fi
	
	if [ ! -d "$folderPath" ]; then
		return 1
	fi
	
	if [ ! -r "$folderPath" ]; then
		return 1
	fi
	
	if [ -x "$folderPath" ]; then
		return 0
	fi
	
	return 1
}

core_path_isReadableAndSearchableAndWritableFolderPath()
{
	core_path_isReadableAndSearchableFolderPath "$1"
	
	local folderPath="$1"
	
	if [ -w "$folderPath" ]; then
		return 0
	fi
	
	return 1
}
