Du läser för närvarande dokumentationen för:
ECF_OpenFile
ECF_OpenFile opens a file on a mounted file system.
ECF_ErrorCode ECF_OpenFile(
   struct ECF_FileHandle *pFileHandle,
   const char *filename,
   uint8_t flags
);
Parameters
pFileHandle
This is a pointer to a struct ECF_FileHandle structure to hold data about the open file. The contents of the struct ECF_FileHandle will be cleared. There is no need to initialize it.
filename
This is the name of the file to open. Files are always specified with their full paths including the drive letter. To open a file called "Log.txt" on drive A you will need to specify the filename: A:\Log.txt (which is "A:\\Log.txt" when entered as a C string) To open a file called "My file.data" in the directory "My folder" on drive B you need to specify the filename: B:\My folder\My file.data ("B:\\My folder\\My file.data" as a C string) The maximum total path length including the trailing NUL character is 260 characters.
flags
Specifies in which mode the file should be opened. Select one of ECF_MODE_READ, ECF_MODE_READ_WRITE and ECF_MODE_APPEND.
ECF_MODE_READ:
Opens the file for reading. Reading will start at the beginning of the file.
ECF_MODE_READ_WRITE:
Opens the file for reading and writing. Reading and writing will start from the beginning of the file. If the file doesn't exist it will be created.
ECF_MODE_APPEND:
Opens the file for reading and writing. Writing the file will write to the end of it. If the file doesn't exist it will be created.
Return value
Returns one of the EcFAT error codes (ECFERR_SUCCESS on success)
Remarks
If the call to ECF_OpenFile was successful you can now use your file handle to call other file operations. You may open the same file several times but you may only open it once in write mode. This enables you to have one process that logs data to a file while another process reads it. On a journaled file system writes to the file system structures are protected but normal data writes are not. If you open the file with ECF_MODE_DATAJOURNAL, data writes will be journaled as well. This means that either the write will either be written in full or not at all (in case of a power loss). You may not write more than one sector size of data in each write (typically 512 or 4096 bytes). Since the journal needs to be written on each write, writes to files opened with ECF_MODE_DATAJOURNAL will be slower than normal.
Example Code
#include <EcFAT/EcFAT.h>

void main(int argc, char **argv)
{
   // ...Mount file system on 'A' here...
   
   struct ECF_FileHandle fileHandle;
   const char *cszMessage = "This will be written to the file\n";

   if(ECF_OpenFile(&fileHandle, "A:\\Log.txt", ECF_MODE_APPEND)
      == ECFERR_SUCCESS)
   {
      // Error checking omitted
      ECF_WriteFile(&fileHandle, cszMessage, strlen(cszMessage));
      ECF_CloseFile(&fileHandle);
   }
}
See also