library/src/filesystem/BP-Filesystem.cc
// Opposite of file get contents.  Attempts to open a file and write data to it.
Opposite of file get contents.  Attempts to open a file and write data to it.
Opposite of file get contents . Attempts to open a file and write data to it .
BP_ERROR_T BP_FilePutContents
(
		char *file_path,
		char *buff,
		size_t buff_size,
		BP_BOOL append
)
{
	if(!file_path)
		return ERR_FAILURE;
	if(!buff)
		return ERR_FAILURE;
	if(!buff_size)
		return ERR_FAILURE;
	if(!BP_StringIsReasonablePrintableString(file_path, bpstrlen(file_path), BP_FALSE, BP_FALSE))
		return ERR_FAILURE;
	FILE * open_file = BP_FOpen(file_path, append ? (char *) "a" : (char *) "w");
	if(!open_file)
		return ERR_FAILURE;
	BP_FWrite(open_file, buff, buff_size);
	BP_FClose(open_file);
	return ERR_SUCCESS;
}
BP_ERROR_T BP_FilePutContents ( char * file_path , char * buff , size_t buff_size , BP_BOOL append ) { if ( ! file_path ) return ERR_FAILURE ; if ( ! buff ) return ERR_FAILURE ; if ( ! buff_size ) return ERR_FAILURE ; if ( ! BP_StringIsReasonablePrintableString ( file_path , bpstrlen ( file_path ) , BP_FALSE , BP_FALSE ) ) return ERR_FAILURE ; FILE * open_file = BP_FOpen ( file_path , append ? ( char * ) " " : ( char * ) " " ) ; if ( ! open_file ) return ERR_FAILURE ; BP_FWrite ( open_file , buff , buff_size ) ; BP_FClose ( open_file ) ; return ERR_SUCCESS ; }
Opposite of file get contents.
Opposite of file get contents .
// ensure we have a path // Run only basic checks on buffer.  Since this is a file-write utility, we // cant get too nitpicky with buffer sanity. // ensure the passed string is reasonable // open the file // read the data into the new buffer // close the file // return indicating success