
void close_append_file_ptr(FILE *pInFIle)
{
if(NULL != pInFIle)
{
fclose(pInFIle);
pInFIle = NULL;
}
}
FILE *open_txt_append_file_ptr(char *fileName)
{
FILE *pInFIle = NULL;
pInFIle = fopen(fileName, "a");
if(NULL == pInFIle)
{
printf("[%s %d %s] fopen(%s) failed\n", __FILE__, __LINE__, __func__, fileName);
return NULL;
}
return pInFIle;
}
void close_txt_append_file_ptr(FILE *pInFIle)
{
close_append_file_ptr(pInFIle);
}
FILE *open_binary_append_file_ptr(char *fileName)
{
FILE *pInFIle = NULL;
pInFIle = fopen(fileName, "a");
if(NULL == pInFIle)
{
printf("[%s %d %s] fopen(%s) failed\n", __FILE__, __LINE__, __func__, fileName);
return NULL;
}
return pInFIle;
}
int write_binary_data(FILE *pBinaryFile, uint8_t *data, uint32_t dataSize)
{
if((NULL == pBinaryFile) || (NULL == data) || (0 == dataSize))
{
printf("[%s %d %s] (NULL == pBinaryFile) || (NULL == data) || (0 == dataSize) failed\n", __FILE__, __LINE__, __func__);
return -1;
}
return fwrite(data, 1, dataSize, pBinaryFile);
return 0;
}
int write_txt_data(FILE *pTxtFile, uint32_t frameDataSize)
{
char tmp[9] = "";
if(NULL == pTxtFile)
{
printf("[%s %d %s] NULL == pTxtFile failed\n", __FILE__, __LINE__, __func__);
return -1;
}
sprintf(tmp, "%d\n", frameDataSize);
return fwrite(tmp, 1, strlen(tmp), pTxtFile);
}
void close_binary_append_file_ptr(FILE *pInFIle)
{
close_append_file_ptr(pInFIle);
}
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。