library/src/utility/BP-FileGeneralUtilities.cc
//! returns ERR_FAILURE or ERR_SUCCESS (file is there and can be opened) depending on if the file is there and readable.
returns ERR_FAILURE or ERR_SUCCESS (file is there and can be opened) depending on if the file is there and readable.
returns ERR_FAILURE or ERR_SUCCESS ( file is there and can be opened ) depending on if the file is there and readable .
BP_ERROR_T BP_FileAtPathExistsAndIsReadable(char *file_path)
{
	if(!file_path)
		return ERR_FAILURE;
	if(!BP_StringIsReasonableForUnixEXT4Filename(file_path, bpstrlen(file_path), BP_FALSE))
		return ERR_FAILURE;
	struct stat sb;
	BP_ZERO_STACK(sb);
	stat(file_path, &sb);
	if(sb.st_mode & S_IRUSR)
		return ERR_SUCCESS;
	return ERR_FAILURE;
}
BP_ERROR_T BP_FileAtPathExistsAndIsReadable ( char * file_path ) { if ( ! file_path ) return ERR_FAILURE ; if ( ! BP_StringIsReasonableForUnixEXT4Filename ( file_path , bpstrlen ( file_path ) , BP_FALSE ) ) return ERR_FAILURE ; struct stat sb ; BP_ZERO_STACK ( sb ) ; stat ( file_path , & sb ) ; if ( sb . st_mode & S_IRUSR ) return ERR_SUCCESS ; return ERR_FAILURE ; }
returns ERR_FAILURE or ERR_SUCCESS (file is there and can be opened) depending on if the file is there and readable.
returns ERR_FAILURE or ERR_SUCCESS ( file is there and can be opened ) depending on if the file is there and readable .
// ensure pointer is not null // ensure path is reasonable printable // create sb buffer and zero it // run stat to determine if it's executable // if stat reports its executable, return error success // file is not readable