library/src/blockclass/BP-BlockClass.cc
// relies on FileGetContents(), generates an ascii sha1 from a file
relies on FileGetContents(), generates an ascii sha1 from a file
relies on FileGetContents () generates an ascii sha1 from a file
bool Block::GenSHA1FromFile(char *filename)
{
	if(!filename)
		return ERR_FAILURE;
	if(BP_FileAtPathExistsAndIsReadable(filename) != ERR_SUCCESS)
		return ERR_FAILURE;
	Block * get_contents = new Block();
	if(get_contents->FileGetContents(filename) == ERR_FAILURE)
	{
		delete get_contents;
		return ERR_FAILURE;
	}
	if(!this->GenSHA1(get_contents->got_contents, get_contents->got_contents_size))
	{
		delete get_contents;
		return ERR_FAILURE;
	}
	delete get_contents;
	return ERR_SUCCESS;
}
bool Block :: GenSHA1FromFile ( char * filename ) { if ( ! filename ) return ERR_FAILURE ; if ( BP_FileAtPathExistsAndIsReadable ( filename ) != ERR_SUCCESS ) return ERR_FAILURE ; Block * get_contents = new Block ( ) ; if ( get_contents -> FileGetContents ( filename ) == ERR_FAILURE ) { delete get_contents ; return ERR_FAILURE ; } if ( ! this -> GenSHA1 ( get_contents -> got_contents , get_contents -> got_contents_size ) ) { delete get_contents ; return ERR_FAILURE ; } delete get_contents ; return ERR_SUCCESS ; }
relies on FileGetContents(), generates an ascii sha1 from a file
relies on FileGetContents () generates an ascii sha1 from a file
// ensure we have a filename // ensure the filename exists and is readable // retrieve contents // attempt to get contents // destroy the block before returning // return indicating failure // create sha value using local tailqueue allocator // destroy the block used for gathering file data // return the content of sha1 routine