Open and Close

 

 

#include <stdio.h>

#include <string.h>

#include <stdarg.h>

 

#include "m2m_type.h"

#include "m2m_fs_api.h"

#include "m2m_hw_api.h"

 

CHAR  *file_name = "goofy";

M2M_API_RESULT  API_Result;

M2M_T_FS_HANDLE file_handle = NULL;

.........

.........

 

file_handle = m2m_fs_open(file_name, M2M_FS_OPEN_WRITE);

if(file_handle == NULL)

 {

   PrintToUart("M2M_FS_OPEN_WRITE, NULL");                /* See chapter 19.1.8 PrintToUart */

   /* use m2m_fs_last_error() to know error details */

   return;

 }

else

 {

   PrintToUart("M2M_FS_OPEN_WRITE, SUCCESS");

 }

 

.......

.......

 

API_Result_Close = m2m_fs_close(file_handle); 

if(API_Result_Close == M2M_API_RESULT_INVALID_ARG)          

 {        

   PrintToUart("close %u, INVALID ARGUMENT", Id);       

   /* use m2m_fs_last_error() to know error details */    

   return;          

 }        

else if (API_Result_Close == M2M_API_RESULT_FAIL)    

 {        

   PrintToUart("close %u, FAIL", Id);      

   /* use m2m_fs_last_error() to know error details */    

   return;          

 }        

else if (API_Result_Close == M2M_API_RESULT_SUCCESS)        

 {        

  PrintToUart("close %u, SUCCESS", Id);            

 }        

 

...........

...........